I want to change the image from normal to brighter when it’s on hover, My code:
<div class="nkhome">
<a href="Home.html"><img src="Images/btnhome.png" /></a>
</div>
.nkhome{
margin-left:260px;
top:170px;
position:absolute;
width:59px;
height:59px;
}
.nkhome a img:hover {
background:url(Images/btnhomeh.png);
position:absolute;
top:0px;
}
Why doesn’t work the hover? When my mouse is on it, it shows the first image, not the hover image.
You’ve got an
atag containing animgtag. That’s your normal state.You then add a
background-imageas your hover state, and it’s appearing in the background of youratag – behind theimgtag.You should probably create a CSS sprite and use background positions, but this should get you started:
This A List Apart Article from 2004 is still relevant, and will give you some background about sprites, and why it’s a good idea to use them instead of two different images. It’s a lot better written than anything I could explain to you.