CSS - Sprite Rollover Navigation

by flatiron_school

HTML

<a href="#">SEO friendly text here</a>

CSS

a {
    display: block;
    width: 185px;
    height: 300px;
    overflow: hidden; /* sets overflow outsid ethe element to hidden */
    white-space: nowrap; /* prevent line breaks (text wrapping) */
    text-indent: 100%; /* indents text outside the viewable area */
    background: url(http://fc08.deviantart.net/fs70/f/2012/295/e/c/john_sprite_sheet_part_1_by_blahjerry-d5imaq2.png) no-repeat; /* set background image */
}

a:hover {
    background-position: -185px 0; /* background-position accepts two values the first being horizontal movement and the second being vertical movement. this will re-position image to left 185px on hover */
}

JavaScript

// How do I create a sprite rollover image?