• 实现图片滚动


    简要截图:

     简要代码:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>滚动图片效果展示</title>
        <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.js"></script>
        <script src="http://cdn.bootcss.com/velocity/1.2.3/velocity.js"></script>
        <style type="text/css">
           div:not(:last-of-type){
               80%;height:750px;margin:0 auto;
           }
           div:first-of-type{background:url(imgs/1.jpg);background-size:cover;}
           div:nth-of-type(2){background:url(imgs/2.jpg);background-size:cover;}
           div:nth-of-type(3){background:url(imgs/3.jpg);background-size:cover;}
           div:nth-of-type(4){background:url(imgs/4.jpg);background-size:cover;}
           div:nth-of-type(5){background:url(imgs/5.jpg);background-size:cover;}
           div:nth-of-type(6){background:url(imgs/6.jpg);background-size:cover;}
           div:nth-of-type(7){background:url(imgs/7.jpg);background-size:cover;}
           div:last-of-type{position:fixed;top:130px;right:50px;}
           div:last-of-type ul{list-style:none;}
           div:last-of-type ul li{30px;height:30px;background:black;margin:3px;color:white;text-align:center;line-height:30px;}
            div:last-of-type ul li:hover {cursor:pointer; }
         
        </style>
    </head>
    <body>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div>
            <ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul>
        </div>
    </body>
    </html>
    <script type="text/javascript">
        $("div:last ul li").click(function () {
            var numLi = $(this).text();
            $("div:last ul li").css({ "background-color": "black", "color": "white" });//每次都对所有的li背景色进行初始化,点击哪个改变哪个li的背景颜色和字体颜色
            switch (numLi) {
                case "1": $("div:first").velocity("scroll", { duration: 300 }); $(this).css({"background-color":"white","color":"black"});break;
                case "2": $("div:eq(1)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
                case "3": $("div:eq(2)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
                case "4": $("div:eq(3)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
                case "5": $("div:eq(4)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
                case "6": $("div:eq(5)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
                case "7": $("div:eq(6)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
    
            }
        });
     
    </script>
  • 相关阅读:
    获取时间对象
    定时器
    undefined与return
    获取设置非行间样式
    NaN
    return,break与continue的区别
    数据类型
    程序的机器级表示
    计算机内数字的表示
    计算机系统漫游
  • 原文地址:https://www.cnblogs.com/shuai7boy/p/5537346.html
Copyright © 2020-2023  润新知