<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>
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8589.html