HTML
01 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 02 <html xmlns="http://www.w3.org/1999/xhtml"> 03 <head> 04 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 05 <title>Animated Label Navigation Menu</title> 06 07 <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> 08 09 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script> 10 <script src="js/animate-bg.js" type="text/javascript"></script> 11 <script src="js/scripts.js" type="text/javascript"></script> 12 </head> 13 14 <body> 15 16 <div id="container"> 17 <ul id="nav"> 18 <li><a href="#">Home</a></li> 19 <li><a href="#">About</a></li> 20 <li><a href="#">Work</a></li> 21 <li><a href="#">Contact</a></li> 22 </ul> 23 </div> 24 25 </body> 26 </html>
CSS
01 body, div, h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, img, form, fieldset, input, textarea, blockquote { 02 margin: 0; padding: 0; border: 0; 03 } 04 05 body { 06 background: #f5f0e0 url(images/noise.png); 07 } 08 09 #container { 10 height: 800px; 11 background: url(images/bg.jpg) center top no-repeat; 12 } 13 14 ul#nav { 15 width: 700px; margin: 0 auto; text-align: center; overflow: hidden; 16 } 17 ul#nav li { 18 float: left; list-style: none; 19 } 20 ul#nav li a { 21 display: block; width: 97px; height: 77px; 22 padding: 72px 0 0 0; margin: 0 32px 0 32px; 23 font: bold 16px Helvetica, Arial, Sans-Serif; text-transform: uppercase; 24 color: #9c5959; text-shadow: 0 1px 3px #c4bda6; text-decoration: none; 25 26 background: url(images/label.png) 0 -149px no-repeat; 27 } 28 ul#nav li a:hover { 29 background: url(images/label.png) 0 0 no-repeat; 30 color: #eee9d9; text-shadow: 0 2px 3px #4c2222; 31 } 32 33 ul#nav li a.js:hover { 34 background: url(images/label.png) 0 -149px no-repeat; 35 }
Эффект jQuery 01 $(document).ready(function() { 02 $("ul#nav li a").addClass("js"); 03 $("ul#nav li a").hover( 04 function () { 05 $(this).stop(true,true).animate({backgroundPosition:"(0 0)"}, 200); 06 $(this).animate({backgroundPosition:"(0 -5px)"}, 150); 07 }, 08 function () { 09 $(this).animate({backgroundPosition:"(0 -149px)"}, 200); 10 11 } 12 ); 13 14 });
|