zoukankan      html  css  js  c++  java
  • 仿途牛导航

    <!DOCTYPE html>
    <html>
    <head>
    <title>xx</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8;"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <style>
    *{margin:0;padding:0;}
    li{
    height:50px;200px;
    }
    span{
    display:inline-block;200px;height:50px;border:1px solid #999;text-align:center;line-height:50px;cursor:pointer;
    }
    @media screen and (max-1100px){
    li{
    height:50px;100px;
    }
    span{
    display:inline-block;100px;height:50px;border:1px solid #999;text-align:center;line-height:50px;cursor:pointer;
    }
    }
    </style>
    </head>
    <body>
    <div style="margin:0 auto;padding:0;1100px;" id="all">
    <div style="100%;height:900px;background:red;" >
    </div>
    <div style="100%;height:400px;background:yellow;">
    </div>
    <div style="100%;height:400px;background:black;">
    </div>
    <div style="100%;height:400px;background:green;">
    </div>
    <div style="100%;height:400px;background:blue;">
    </div>
    <div style="100%;height:400px;background:red;">
    </div>
    </div>
    <div style="display:none;position:fixed;top:100px;left:200px;200px;" id="xx">
    <ul style="list-style-type:none;margin:0;padding:0;">

    <li ><span >选择黄色</span></li>
    <li ><span >选择灰色</span></li>
    <li ><span >选择绿色</span></li>
    <li ><span >选择蓝色</span></li>

    </ul>
    </div>


    </body>
    <script src="jquery.js" ></script>
    <script>
    $(function(){
    tag = true;
    var arr = [ "yellow", "#999", "green", "blue" ];
    var $xx = $("#xx");
    var $span = $("ul li ");
    var heightVal = $(document).height()-400;
    $(window).scroll(function(){
    if(tag){
    var topVal = $(window).scrollTop();
    if(topVal>500){
    var a = count(topVal,heightVal);
    $span.eq(a).find("span").css("background",arr[a]);
    $span.eq(a).siblings("li").find("span").css("background","");
    $xx.css("display","block");
    }else{
    $xx.css("display","none");
    }
    }


    });


    function count(c,d){
    var e = parseInt((d-c)/400);
    return 4-e;
    }

    $span.each(function(){
    $(this).on("click",function(){
    tag = false;
    var index = $(this).index();
    $span.eq(index).find("span").css("background",arr[index]);
    $span.eq(index).siblings("li").find("span").css("background","");
    $("html,body").animate({scrollTop:$("#all div").eq(index+1).offset().top}, "fast","",function(){
    tag = true;
    });
    });
    });
    });
    </script>
    </html>

     
  • 相关阅读:
    C# MessageBox.Show()超时后 自动关闭
    WPF中的依赖属性和附加属性
    c# 获取当前活动窗口句柄,获取窗口大小及位置
    c# 数组间相互转换 int[] string[] object[]
    WPF中判断DataGrid增加复选框和头部全选,以及判断哪一行的checkbox被选中
    WPF DataGridTemplateColumn添加按钮和按钮事件获取行参数
    WPF 自定义分页控件 ---- DataPager
    WPF的MVVM模式给ComboBox绑定数据和读取
    DataBinding 绑定计算表达式
    c# 调用方法超时直接返回的功能
  • 原文地址:https://www.cnblogs.com/qianduanxiaocaij/p/5102486.html
Copyright © 2011-2022 走看看