滚动条大于120px时,判断pc端的情况下,导航条固定定位

 
//滚动条大于120px时,判断pc端的情况下,导航条固定定位
    $(window).scroll(function(){
        var viewWidth=$(document).width()
        var top=$(document).scrollTop();
        if(viewWidth>=768&&top>=120){
            $('.d_head_nav').css({
                'position':'fixed',
                'top':"0px",
                "width":'100%'
            })
        }else{
            $('.d_head_nav').css({
                'position':'relative'
            })
        }
    })

 

posted @ 2017-09-14 14:14  LIULIULIU666  阅读(265)  评论(0编辑  收藏  举报