<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 ;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 restart_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>