zoukankan      html  css  js  c++  java
  • 页面滑动到一定距离导航固定及回到顶部


    .fixednav {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
    }
    <script>
            var nav = $("#newnav"); //得到导航对象
                            var win = $(window); //得到窗口对象
                            var sc = $(document); //得到document文档对象。
                            win.scroll(function() {
                                    if(sc.scrollTop() >= 210) {
                                            nav.addClass("fixednav");
                                    } else {
                                            nav.removeClass("fixednav");
                                    }
                            })


    //回到顶部
                            $(".topR").click(function(){
                                            $('html,body').animate({
                    scrollTop: '0px'
            }, 300);
                                    })
                                    
                    
    </script>

  • 相关阅读:
    Gym
    Gym
    Gym
    Gym
    Gym
    bzoj 2734: [HNOI2012]集合选数
    bzoj 1068: [SCOI2007]压缩
    HDU 2899 Strange fuction
    hihocoder #1142 : 三分·三分求极值
    HDU 2824 The Euler function
  • 原文地址:https://www.cnblogs.com/zyl-930826/p/8649423.html
Copyright © 2011-2022 走看看