You can do this with less CSS as follows:
.myClass { background: url(../Images/Sprite.png) no-repeat; height: 20px; width: 40px; background-position: -40px 0; display: block; } .myClass:hover { background-position: -40px -20px; }
That the class class="myClass" would not only have an image in it, nothing else. It can be a <a> an <input> or a normal <div> , whatever you wish.
This is a background image ... but this is the element you are looking at, nothing in front of this background. Just because you use a background-image for a property does not mean that it is not a foreground element ... like a button that you can click on. You can do it like this:
<input type="button" class="myClass" />
Nick Craver Mar 11 '10 at 19:58 2010-03-11 19:58
source share