Web Design expert - XHTML & CSS developer - jQuery builder - Graphic Designer
FFA employee - Husband - Step Dad - Brother - Son - Believer - Basketball player
Oil Painter - Percussionist - Pitt Illumni - ESPN Fanatic - Red Box enthusiast

Blog | Dec 4, 2011

Easy CSS Rollover Effect

Have you ever been in a situation where a link failed to show its image after you hovered it properly? Maybe it just didn't catch initially, but every other time it worked? Guess what - don't waist your time or take the risk in designing multiple images for rollovers anymore. Simply design "one" image with 3 different states (top middle bottom), and properly adjust the CSS background position of this "one" image in 3 different hover actions. This example is very simple and easily tackles the issue. Good luck!

#myRoll {
padding:0;
margin:0 10px 0 0;
display:block;
width:54px;
height:56px;
overflow:hidden;
text-indent: -10000px;
font-size:0;
line-height:0;
background: transparent url(your image) no-repeat center -56px;
}

#myRoll:hover {
/*set your initial rolling position*/
background-position:center 0px;
}

#myRoll:active {
/*set your active or visited positioning*/
background-position:center -112px;
}


Web Design Portfolio

Graphic Design Portfolio



[X]

Friends & Inspiration

Voxiant

Insight Writer

CMS Made Simple

OscMax


You need Flash player 8+ and JavaScript enabled to view this video.

Play | Pause | Stop
[graphics/box.jpg]
[graphics/yum.jpg]
[graphics/ptso.jpg]
[graphics/ffa.jpg]
[graphics/twitter.jpg]
[graphics/storm.jpg]
[graphics/clouds.jpg]
[graphics/redbirdrmx.jpg]
[graphics/crush2pieces.jpg]
[graphics/floral.jpg]
[graphics/esv.jpg]
[graphics/dbz_spirit_bomb.jpg]
[graphics/loveyou.jpg]
[graphics/abstract.jpg]
[graphics/cambodiav2.jpg]