zoukankan      html  css  js  c++  java
  • 纵向轮播图的封装

    本人纯原生手写!!

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            *{margin: 0;padding: 0;}
            a{text-decoration: none;}
            .container{
                position: relative;
                 360px;
                height: 660px;
                margin:300px auto 0 auto;
                background-color: #666;
                box-shadow: 0 0 5px green;
                overflow: hidden;
            }
            .wrap{
                position: absolute;
                height: 1428px;
                 308px;
                z-index: 1;
                background-color: purple;
                margin-left: 26px;
            }
            .img{
                /* float: left; */
                 308px;
                height: 178px;
                line-height: 178px;
                font-size: 50px;
                text-align: center;
                margin-top: 26px;
            }
    
            .arrow{
                position: absolute;
                 110px;
                height: 30px;
                line-height: 30px;
                border: 1px solid #C2000B;
                font-size: 24px;
                border-radius: 10px;
                bottom: 5px;
                z-index: 2;
                padding:0px 14px;
                color: red;
                background-color: rgba(0,0,0,0.2);
                text-align: center;
            }
            .arrow_top{
                left: 26px;
                background-color: #fff;
            }
            .arrow_bottom{
                right: 26px;
                color: #fff;
                background-color: #C2000B;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="wrap" style="top: -204px">
                <div class="img" style="background: cyan;">5</div>
                <div class="img" style="background: red;">1</div>
                <div class="img" style="background: orange;">2</div>
                <div class="img" style="background: yellow;">3</div>
                <div class="img" style="background: green;">4</div>
                <div class="img" style="background: cyan;">5</div>
                <div class="img" style="background: red;">1</div>
            </div>
            <a href="javascript:;" class="arrow arrow_top">↓</a>
            <a href="javascript:;" class="arrow arrow_bottom">↑</a>
        </div>
    </body>
    <script>
        var wrap = document.querySelector('.wrap');
        var next = document.querySelector('.arrow_top');
        var prev = document.querySelector('.arrow_bottom');
        console.log(wrap, prev, next);
    
        next.onclick = function () {
            console.log('下');
            next_pic();
        }
        prev.onclick = function () {
            console.log('上');
            prev_pic();
        }
        // 点击下一张
        function next_pic () {
            var newTop;
            if (wrap.style.top === '-816px') {
                newTop = 0;
            } else {
                newTop = parseInt(wrap.style.top) -204;
            }
            wrap.style.top = newTop + "px";
        }
    
        // 点击上一张
        function prev_pic () {
            var newTop;
            if (wrap.style.top === "0px") {
                newTop = -816;
            } else {
                newTop = parseInt(wrap.style.top) + 204;
            }
            wrap.style.top = newTop + "px";
        }
    </script>
    </html>
    

      

  • 相关阅读:
    alpine下ruby安装sass compass报 Error installing compass 错误的解决方案
    Andoid项目中增加openCV的依赖
    appium教程_4.adb常用命令
    appium教程_2.概念加深
    appium教程_1.基础概念认知
    windows下查看进程(进阶)
    linux下安装google-chrome浏览器和chromedriver
    钉钉内网穿透windows启动命令
    Docker
    HTTP协议
  • 原文地址:https://www.cnblogs.com/wufenfen/p/13845592.html
Copyright © 2011-2022 走看看