【转】仿淘宝 智能跟随菜单提示栏 智能浮动的菜单
转自:http://guangqiang.iteye.com/blog/1699940
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script><script type="text/javascript"> $.fn.smartFloat = function() { var position = function(element) { var top = element.position().top, pos = element.css("position");$(window).scroll(function() { var scrolls = $(this).scrollTop(); if (scrolls > top) {if (window.XMLHttpRequest) { element.css({position: "fixed",top: 0});} else { element.css({top: scrolls});} }else {element.css({position: pos, top: top}); } }); }; return $(this).each(function() {position($(this)); });};</script><script>//绑定$(document).ready(function(){ $("#nav_left_layout").smartFloat();});
<div id="nav_left_layout"></div>