圖片作為背景并且是鏈接的寫法(背景圖片加鏈接)

字號:


    圖片作為背景,并且是鏈接的寫法。例如網(wǎng)站的logo圖片。例如:土豆的logo圖片
    <a >土豆網(wǎng)</a>
    a {display: block;width: 170px;height: 42px;text-indent: -9999px;background: url(/skin/__g/img/ui/nav/v2_v6.png) 0 0 no-repeat;}
    由于z-indent的原因土豆網(wǎng)三個字是不會顯示的。title屬性是鼠標(biāo)指向會顯示的文本。
    <a><span>鏈接背景圖片,在正常情況下是顯示不全的,因為<a>鏈接是行內(nèi)元素,并且對于a標(biāo)簽css中width height屬性失效。
    改進(jìn)方法,就是css中display:block;或者display:inline-block;然后設(shè)置width和height。