zoukankan      html  css  js  c++  java
  • 层级轮播图

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            * {
                margin: 0;
                padding: 0;
            }
    
            ul, ol {
                list-style: none;
            }
    
            .wrap {
                 650px;
                height: 250px;
                margin: 100px auto 0;
                position: relative;
                overflow: hidden;
            }
            .wrap ol {
                margin-top: 50px;
            }
    
            .wrap img {
                display: block;
            }
    
            .wrap ul {
                height: 250px;
                z-index: 1;
                position: relative;
            }
    
            .wrap ol {
                height: 30px;
                z-index: 2;
                position: absolute;
                bottom: 0;
                right: 0;
               
            }
    
            .wrap > ul > li {
                position: absolute;
                top: 0;
                left: 0;
            }
    
            .wrap > ol > li {
                float: left;
                 20px;
                height: 20px;
                text-align: center;
                line-height: 20px;
                border: 1px solid white;
              
               border-radius: 10px;
                background: Gray;
               
            }
    
            .wrap > ol > li:hover {
                cursor: pointer;
            }
    
            .wrap li.active {
                padding: 1px;
                color: orange;
                margin-top: -2px;
               
                border: 1px solid orange;
                
            }
        </style>
      <script type="text/javascript" src="jquery-1.11.1.min.js" ></script>
        <script>
            $(document).ready(function () {
                var zIndex = 0;
                $(".wrap > ol > li").mouseenter(function () {
                    zIndex++;
                    $(this).addClass("active").siblings().removeClass("active");
                    $(".wrap > ul > li")
                            .eq($(this).index())
                            .css({
                                "z-index": zIndex,
                                "left": 650
                            })
                            .animate({
                                "left": 0
                            }, 1000);
                });
            });
        </script>
    </head>
    <body>
    <div class="wrap">
        <ul>
            <li style="z-index:1;"><img src="img/1.jpg" alt=""/></li>
            <li><img src="img/2.jpg" alt=""/></li>
            <li><img src="img/3.jpg" alt=""/></li>
            <li><img src="img/4.jpg" alt=""/></li>
            <li><img src="img/5.jpg" alt=""/></li>
        </ul>
        <ol>
            <li class="active">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ol>
    </div>
    </body>
    </html>

     

  • 相关阅读:
    tap事件的原理详解
    获取地理位置
    获取高度
    JSON字符串与JSON对象的区别
    zepto方法
    javascript 中 click 和onclick有什么区别呢
    oninput,onpropertychange,onchange的用法和区别
    js实时监听input中值得变化
    sql lock
    数据库SQL优化大总结
  • 原文地址:https://www.cnblogs.com/houjiie/p/6032427.html
Copyright © 2011-2022 走看看