cdiego

Menú animado Jquery

Jun 2nd, 2012
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.79 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5.     <title>Menú Animado</title>
  6.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
  7.     <script src="http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js" type="text/javascript"></script>
  8.    
  9.     <style>
  10.         #menu{
  11.             font-size: 2em;
  12.         }
  13.        
  14.         #menu ul{
  15.             padding: 0;
  16.             margin: 0;
  17.         }
  18.        
  19.         #menu li{
  20.             display: inline;
  21.             padding:0;
  22.             margin: 0;
  23.         }
  24.        
  25.         #menu a{
  26.             padding: 5px;
  27.             text-decoration: none;
  28.         }
  29.        
  30.         #sombra{
  31.             position: absolute;
  32.             top: 0;
  33.             background-color: green;
  34.             z-index: -1;
  35.         }
  36.     </style>
  37.     <script>
  38.         $(document).ready(function(){
  39.             $("<div id='sombra'></div>").css({
  40.                 width:0,
  41.                 height: $("#menu a").height()+10
  42.             }).appendTo("#menu");
  43.            
  44.             //FUNCION PARA ANIMAR LA SOMBRA CUANDO SE
  45.             //PASE EL MOUSE SOBRE LOS "a" DE LOS "li"
  46.             $("#menu a").hover(function(){
  47.                 $("#sombra").animate({
  48.                     width:$(this).width() +10,
  49.                     left:$(this).position().left
  50.                 },
  51.                 {
  52.                     duration:"medium",
  53.                     easing:"easeOutElastic",
  54.                     queue:false
  55.                 });
  56.             });
  57.         });
  58.     </script>
  59. </head>
  60. <body>
  61. <div id="menu">
  62.     <ul>
  63.         <li><a href="">INICIO</a></li>
  64.         <li><a href="">NOTICIAS</a></li>
  65.         <li><a href="">FORO</a></li>
  66.         <li><a href="">BLOG</a></li>
  67.     </ul>    
  68. </div>
  69. </body>
  70. </html>
Advertisement
Add Comment
Please, Sign In to add comment