Information
Based on a demonstration by Avalonstar
This is a demonstration of the :hover and :active/:focus states of a link. Hover the mouse over the front, middle and rear of the image to reveal a higher definition image and click the hover image to reveal the highest definition image. Opera users will need to hold the mouse button for the third image to remain on the screen.
The original demonstration by Avalonstar moved the link background whereas this demonstration keeps the background in the same place and moves the link instead for :hover but moves the background for :active and :focus.
This car image has been chosen because it fits my layout and demonstrates the three different image states fairly well (and doesn't infringe any copyrights).
Tested in IE5.5, IE6, Firefox 1.06, Opera 8, NN8, Mozilla 1.7.5
Cascading Style Sheet
#car {
width:435px;
height:143px;
margin:10px auto;
padding:0;
position:relative;
list-style-type:none;
background:url(../images/car2.jpg);
}
#car li {
display:block;
height:143px;
width:145px;
position:absolute;
left:0;
top:0;
overflow:hidden;
}
#car li#section2 {
left:145px;
}
#car li#section3 {
left:290px;
}
a:visited {
color:#000;
}
#car li a, #car li a:visited {
position:absolute;
width:145px;
height:429px;
background: url(../images/car2.jpg);
text-indent: -100em;
overflow:hidden;
}
#car li#section2 a, #car li#section2 a:visited {
background-position:-145px 0;
}
#car li#section3 a, #car li#section3 a:visited {
background-position:-290px 0;
}
#car li a:hover {
margin:0; top:-143px;
}
#car li a:active, #car li a:focus {
padding:0;
top:0;
height:143px;
background-position:left bottom;
}
#car li#section2 a:active, #car li#section2 a:focus {
background-position:center bottom;
}
#car li#section3 a:active, #car li#section3 a:focus {
background-position:right bottom;
}
xhtml
<ul id="car"> <li id="section1"><a href="#nogo">Section One</a></li> <li id="section2"><a href="#nogo">Section Two</a></li> <li id="section3"><a href="#nogo">Section Three</a></li> </ul>
Copyright
You may use this method on your personal 'non-profit' web site without seeking my permission. A link back to CSSplay is always appreciated.
Commercial usage is also permitted without seeking approval, but I would ask that a donation is considered to support my work on CSSPlay.
If you are having problems integrating any of my demonstrations into your website then I now offer a service to fault find and correct any errors that you may have introduced. Please email me for more information.
- Each week the Creare Group produce video tutorials for SEO and tips and tricks for the web design industry.
- We offer nothing but the highest quality SEO, Social Media Optimisation And PPC services to businesses in London
- Register Domain Name
- web designers company providing number 1 services for website design and SEO
- IT Support Bristol
- Web Design
- Website Designers - Compare quotes from local website designers
- Top Website Design Company CWD.
Get the Perfect Website! - Web Design Birmingham - Expert web design, marketing and support
- UK's white label Web Design specialist
- Affordable Web Design from EU Design Studio





