页面滑动至某处,固定导航。

<div class="download">我是要固定的</div>
.download.fixed {
    overflow: hidden;
    position: fixed;
    width: 100%;
    top: 0;
    background: #fff;
    z-index: 998;
}
        var downLoadBar = $('.download');
    var downSetTop = downLoadBar.offset().top;
    $(window).on('scroll', function() {
        var nowScroll = $(this).scrollTop()
        if(nowScroll > downSetTop) {
            downLoadBar.addClass('fixed')
        } else {
            downLoadBar.removeClass('fixed')
        }
    })    

posted @ 2017-04-18 18:12  雪明瑶  阅读(306)  评论(0编辑  收藏  举报