zoukankan      html  css  js  c++  java
  • scroll 滚动到指定位置触发事件 and 点击一按钮/链接让页面定位在指定的位置

    scroll 滚动到指定位置触发事件:
    $(function(){
    $(window).scroll(function() {
    var s =$(window).scrollTop();
    if (s>=782) {//782是导航条离页面顶部的距离(px)
    $('.nav').addClass('fixednav');
    }
    else{
    $('.nav').removeClass('fixednav');
    }
    });
    });
    .fixednav{
    position:fixed;
    top:0px;
    left:0px;
    100%;
    z-index:100000;
    _position:absolute;
    _top:expression(eval(document.documentElement.scrollTop));
    }

    点击一按钮/链接让页面定位在指定的位置:
    <div class="nav">
    <a href="#aaa">导航1</a>
    <a href="#bbb">导航2</a>
    <a href="#ccc">导航3</a>
    <a href="#ddd">导航4</a>
    </div>


    通过锚点实现
    <a name="aaa" id="aaa"></a>
    <a name="bbb" id="bbb"></a>
    <a name="ccc" id="ccc"></a>
    <a name="ddd" id="ddd"></a>

    鼠标滚动到底部事件:
    $(window).scroll(function() {
    if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
    $(".foot").css('opacity','1');
    } else {
    $(".foot").css('opacity','.3');
    }
    });
     
     
     
  • 相关阅读:
    map初始化
    map
    sort排序
    455分发饼干
    392判断子序列
    vector遍历
    vector删除数据
    VC-进程间通信(InterProcess Communication,IPC)
    Oracle 11g 安装和登录(windows)
    控制台输出宽字符wchar_t的中文显示问题
  • 原文地址:https://www.cnblogs.com/mo-cha/p/6023313.html
Copyright © 2011-2022 走看看