CSS button rollovers Image sprites
I first learned this here, I hope it will be helpful for some.
- Merge the two images as one.

you will notice the image is 60 pixels in height I have placed the guide at 30 pixels and place the rollover text on the guide. - The markup is simple:
<a class="rollover" href="link/" title="Rollover Link">Rollover</a>
Break down of the code:
<a » the a tag class="rollover" » CSS identifier href="link/" » file location title="Rollover Link" » title tag this good for SEO >Rollover » Link text </a> » Closing tag
- The CSS is simple as well:
a.rollover { background:url(rollover.gif) no-repeat; background-position:top left; display:block; height:30px; width:160px; text-indent:-999px; overflow:hidden; } a:hover.rollover { background-position:bottom left; }Break down of the code:
a.rollover { background:url(rollover.gif) no-repeat; /* places the image in the background of the link */ background-position:top left; /* background position */ display:block; /* this changes the default render style from inline to block creating a "box" */ height:30px; /* sets the height of box */ width:160px; /* set the width of box */ text-indent:-999px; /* pushes the text out of the box */ overflow:hidden; /* this hides the text and lower part of the image that is outside the defined box */ } a:hover.rollover { background-position:bottom left; /* slides the image up creating the rollover effect. */ } -
In action: Rollover
Taged as: css | navigation design | sprites Posted in: Web Design
Share this post: Stumble upon it Digg It Add to delicious Share on Twitter Share on Facebook
Great point and very interesting food for thought. I’m not sure I have any clients I can replicate this with, but will bear in mind for the future. Regards
I like your post. Good stuff. Keep them coming
…