<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{위치:absolute;top:100px;배경:#4b4a4a ;width:100%;margin:0 auto;clear:both;overflow:hidden;z-index:998;left: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>function 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></script> <br><br> </div>效果图如下: <br><br>