<script type="text/javascript"> var margintop = $("#header").offset().top //var marginleft = $("#header_cont").offset().left; //alert(margintop) //alert(marginleft) $(window).scroll(function() { var scrtop = $(document).scrollTop(); if(scrtop<margintop){ $(‘#header‘).css({ position: ‘absolute‘, top: margintop, left:‘0‘ }); return false; } $(‘#header‘).css({ position: ‘absolute‘, top: scrtop, left:‘0‘ }); }); </script>
时间: 2024-11-13 07:51:15