/ Published in: jQuery
This is a very useful piece of code (html, css, jquery) to have a nice animated floating menu on your page. I totally love it.
I used it with jquery 1.3.2 and up
I used it with jquery 1.3.2 and up
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<h3>Menu</h3> <ul> <li><a onclick="return true;" href="#menu1">Menu1</a></li> <li><a onclick="return true;" href="#menu2">Menu2</a></li> <li><a onclick="return true;" href="#menu3">Menu3</a></li> </ul> /*********************************************** FLOATING MENU *****/ #floatMenu { position:absolute; top:30%; left:10px; width:200px; background-color:#fff; margin:0; padding:0; font-size:11px; border-left:1px solid #ddd; border-right:1px solid #ddd; } #floatMenu h3 { color:#fff; padding:3px; margin:0; background-color:#0E130F; border-bottom:1px solid #ddd; border-top:1px solid #ddd; font-size:13px; text-align:center; } #floatMenu ul { margin:0; padding:0; list-style:none; } #floatMenu ul li { padding-left:10px; background-color:#f5f5f5; border-bottom:1px solid #ddd; border-top:1px solid #ddd; } #floatMenu ul li a { text-decoration:none; font-weight: normal; } #floatMenu ul li a:hover { color: #000; padding-left: 1px; } /* floating menu */ $(function(){ function moveFloatMenu() { var menuOffset = menuYloc.top + $(this).scrollTop() + "px"; $('#floatMenu').animate({top:menuOffset},{duration:500,queue:false}); } menuYloc = $('#floatMenu').offset(); $(window).scroll(moveFloatMenu); moveFloatMenu(); });