
Normally when you mouse over a list of links, the text/background color might change or even the background image might switch to another image. In this tutorial I will show you how to take a normal list of links and add a hover effect so that the bullet image will slide out and another image will then slide in, thus creating an very cool subtle effect.
View Demo: Here
You will need to have a copy of jQuery and the backgroundPosition plugin.
Javascript
$('#nav a') .css( {backgroundPosition: "6px 6px"} ) .mouseover(function(){ $(this).stop() .animate( {backgroundPosition:"(-25px 6px)"}, {duration:200}) .animate( {backgroundPosition:"(-25px -23px)"}, {duration:5}) .animate( {backgroundPosition:"(6px -23px)"}, {duration:200}) }) .mouseout(function(){ $(this).stop() .animate( {backgroundPosition:"(-25px -23px)"}, {duration:200}) .animate( {backgroundPosition:"(-25px 6px)"}, {duration:5}) .animate( {backgroundPosition:"(6px 6px)"}, {duration:200}) })
CSS
ul#nav { border-top: 1px solid #dfdfdf; } ul#nav li { display: inline; } ul#nav li a { display: block; padding: 5px 10px 5px 27px; color: #556565; text-decoration: none; border-bottom: 1px solid #dfdfdf; background: url(images/nav-bg.gif) no-repeat 6px 6px; } ul#nav li a:hover { color: #2b5f1a; background-color: #e5f3d7; }
HTML
<ul id="nav"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Services</a></li> <li><a href="#">Portfolio</a></li> <li><a href="#">Blog</a></li> <li><a href="#">Downloads</a></li> <li><a href="#">Contact</a></li> </ul>
good work mate… go on like that
@Volkan Thanks.
Great tutorial, thanks.
nice but you need to but a .stop() in there to stop it going crazy when you hover over many items quickly.
thanx for codes..
Thanks. for this code
but I found bug script error when run on IE8.
Now! I complete to used this plugin
plz. downlaod new jquery.backgroundPosition.js
http://plugins.jquery.com/project/backgroundPosition-Effect