zoukankan      html  css  js  c++  java
  • 单张滑动tab 组件

    /*
     CSS重置
     * */
    
    body,
    ul,
    ol {
        margin: 0px;
        padding: 0px;
    }
    
    .flash {
         300px;
        height: 420px;
        position: relative;
        overflow: hidden;
    }
    
    
    /*图片css*/
    ul{
         300%;
        position: absolute;
        left: 0px;
        top: 0px;
        transition: 0.5s;
    }
    ul,
    ol {
        list-style: none;
    }
    
    ul li {
         300px;
        height: 420px;
        float: left;
        transition: 0.5s;
    }
    
    ul li:nth-of-type(1) {
        background: green;
    }
    
    ul li:nth-of-type(2) {
        background: blue;
    }
    
    ul li:nth-of-type(3) {
        background: red;
    }
    
    ul li.now {
        z-index: 1;
        opacity: 1;
    }
     
    
    
    /*箭头css*/
    
    nav a {
        position: absolute;
        top: 100px;
        z-index: 999;
        font-size: 36px;
         40px;
        height: 60px;
        line-height: 60px;
        text-align: center;
        text-decoration: none;
    }
    
    nav a:hover {
        background: #333;
        color: white;
    }
    
    nav a:nth-of-type(1) {
        left: 0px;
    }
    
    nav a:nth-of-type(2) {
        right: 0px;
    }
    
    
    /*原点css*/
    
    ol {
        position: absolute;
        bottom: 50px;
        right: 50px;
        z-index: 99;
    }
    
    ol li {
        float: left;
         12px;
        height: 12px;
        border: 2px solid #333;
        background: #ccc;
        border-radius: 50%;
        margin: 0px 5px;
    }
    
    ol li.nowx {
        background: white;
        border-color: red;
        box-shadow: 0px 0px 3px black;
    }
    
    <!DOCTYPE html>
    <html>
    
        <head>
            <meta charset="UTF-8">
            <title></title>
            <link rel="stylesheet" href="flash.css" />
            <style type="text/css">
                #s1,
                #s2,
                #s3 {
                    float: left;
                    margin-left: 10px;
                }
            </style>
        </head>
    
        <body>
    
            <!--
    分析功能:
    1、左右箭头切换图功能
        切换小圆点。
        onclick
        
    2、单击小原点时候也能换图
        点击哪个小圆点,哪个小圆点对应图片显示。
        onclick 
    
    3、淡入淡出效果。
       left
       transition
    
        
    -->
            <section id="s1">
                <div class="flash">
                    <ul>
                        <li class="now">A</li>
                        <li>B</li>
                        <li>C</li>
                    </ul>
                    <ol>
                        <li class="nowx"></li>
                        <li></li>
                        <li></li>
                    </ol>
                    <nav>
                        <a href="#"> &lt; </a>
                        <a href="#"> &gt; </a>
                    </nav>
                </div>
            </section>
    
            <section id="s2">
                <div class="flash">
                    <ul>
                        <li class="now">A</li>
                        <li>B</li>
                        <li>C</li>
                    </ul>
                    <ol>
                        <li class="nowx"></li>
                        <li></li>
                        <li></li>
                    </ol>
                    <nav>
                        <a href="#"> &lt; </a>
                        <a href="#"> &gt; </a>
                    </nav>
                </div>
            </section>
    
            <section id="s3">
                <div class="flash">
                    <ul>
                        <li class="now">A</li>
                        <li>B</li>
                        <li>C</li>
                    </ul>
                    <ol>
                        <li class="nowx"></li>
                        <li></li>
                        <li></li>
                    </ol>
                    <nav>
                        <a href="#"> &lt; </a>
                        <a href="#"> &gt; </a>
                    </nav>
                </div>
            </section>
            <script type="text/javascript">
                function myMove(_id) {
                    var arrs = document.querySelectorAll(_id + " nav a");
                    var lisx = document.querySelectorAll(_id + " ol li");
                    var ul = document.querySelector(_id + " ul");
                    var lis = document.querySelectorAll(_id + " ul li");
                    var flash = document.querySelector(_id + " .flash");
                    var i = 0;
                    //单击左边        
                    arrs[0].onclick = Pre;
                    //单击右边箭头
                    arrs[1].onclick = Next
    
                    function Next() {
                        i < (lis.length - 1) ? i++ : null;
                        ul.style.left = -i * 300 + "px";
                        MyIni(i)
                    }
    
                    function Pre() {
                        i >= 1 ? i-- : null;
                        ul.style.left = -i * 300 + "px";
                        MyIni(i)
                    }
    
                    function MyIni(k) {
                        for(var j = 0; j < lisx.length; j++) {
                            lisx[j].className = "";
                        }
                        lisx[k].className = "nowx";
                    }
    
                }
    
                myMove("#s1");
                myMove("#s2");
                myMove("#s3");
            </script>
        </body>
    
    </html>
  • 相关阅读:
    JavaScript的学习----2.操作BOM对象
    Maven的配置和Eclipse中导入SpringBoot项目一些注意点
    JavaScript学习----1.基础篇
    线程池的学习
    CSS的初步学习
    类的加载细节探索
    反射与注解
    数据结构第二章
    数据结构第一章
    用结构和STL常用算法实现对学生成绩的排序和查找(vector)
  • 原文地址:https://www.cnblogs.com/oklfx/p/7500557.html
Copyright © 2011-2022 走看看