我想要获取背景图像,以便在链接悬停时更改链接。基本上,悬停图像是一种不同的颜色,所以我只是想改变图像的颜色(这是不可能的,我不知道,所以我只是交换图像)。更改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