<script type="text/javascript"> $(document).ready(function(){ var headHeight=$(".top").height()+160; var top=$(".top"); $(window).scroll(function(){ if($(this).scrollTop()>headHeight){ top.addClass("fiex"); } else{ top.removeClass("fiex"); } }) }) </script> .fiex{position: fixed;top: 0; z-index: 1000; width: 100%; background: #fff; height: 159px;} |