我想要獲取背景圖像,以便在鏈接懸停時更改鏈接。基本上,懸停圖像是一種不同的顏色,所以我只是想改變圖像的顏色(這是不可能的,我不知道,所以我只是交換圖像)。更改a:鏈接的背景圖像:hover
的代碼標識顯示:
<a href="/" id="logo"></a>
而CSS:
#logo {
position: absolute;
display: block;
margin-top: 10px;
margin-left: 10px;
background: url('../img/logo.png') no-repeat;
width: 60px;
height: 60px;
}
#logo a:hover {
background: url('../img/logo-blue.png') no-repeat;
}
有我一個更好的方式來顯示會更容易推動這一懸停的標誌?
編輯(添加頁眉CSS):
#header {
height: 75px;
text-align: right;
position: relative;
}
#header h2 {
font-size: 2.5em;
font-weight: 400;
text-transform: uppercase;
letter-spacing: 0.1em;
padding-top: 15px;
}
css sprite。將兩個圖像組合成一個具有並排徽標的圖像。要設置懸停的風格,請使用「background-position」定位背景圖像。這節省了一個http請求。 – Jrod