<div class="codetitle"> <span><a style="CURSOR: pointer" data="75179" class="copybut" id="copybut75179" onclick="doCopy('code75179')"><u>复制代码</u></a></span>如下代码:</div> <div class="codebody" id="code75179"> <br>#topmenu{position:absolute;top:100px;background:#4b4a4a ;宽度:100%;边距:0 自动;清除:两者;溢出:隐藏;z-index:998;左:0} <br><br><script type="text/javascript"> <BR>jQuery(document).ready(function() { <BR>var topmenu = jQuery("#topmenu"); <BR>var topmenu_top = topmenu.offset().top; <BR>reset_topmenu_top(topmenu, topmenu_top) ); <BR>jQuery(window).scroll(function() { <BR>reset_topmenu_top(topmenu, topmenu_top); <BR>}); <BR>函数reset_topmenu_top(topmenu, topmenu_top) { <BR>var document_scroll_top = jQuery(document).scrollTop(); <BR>if (document_scroll_top > topmenu_top) { <BR>topmenu.css('top', document_scroll_top); <BR>} <BR>if (document_scroll_top <= topmenu_top) { <BR>topmenu.css('top', topmenu_top); <BR>} <BR>} <BR></脚本> <BR><BR> </script> </div>效果图如下:<br><br>