zoukankan      html  css  js  c++  java
  • 3D轮播图

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
      <style>
        * {
          padding: 0;
          margin: 0;
          list-style: none;
        }
    
        .view {
          width: 560px;
          height: 300px;
          margin: 100px auto;
          position: relative;
    
        }
    
        ul {
          width: 100%;
          height: 100%;
          transform-style: preserve-3d;
          transform: rotate3d(1, 1, 0, 0deg);
        }
    
        ul>li {
          width: 20%;
          height: 100%;
          float: left;
          transform-style: preserve-3d;
          position: relative;
          /* 过度效果 */
          transition: transform 0.6s;
    
        }
    
        ul>li>span {
          width: 100%;
          height: 100%;
          position: absolute;
          left: 0;
          top: 0;
        }
    
        ul>li>span:nth-of-type(1) {
          background: url("./images/q1.jpg");
          /* 往z轴正方向偏移 */
          transform: translateZ(150px);
        }
    
        ul>li>span:nth-of-type(2) {
          background: url("./images/q2.jpg");
          transform: translateY(-150px) rotateX(90deg);
        }
    
        ul>li>span:nth-of-type(3) {
          background: url("./images/q3.jpg");
          transform: translateZ(-150px) rotateX(-180deg);
    
        }
    
        ul>li>span:nth-of-type(4) {
          background: url("./images/q4.jpg");
          transform: translateY(150px) rotateX(-90deg);
        }
    
        ul>li:nth-of-type(2)>span {
          background-position-x: -100%;
        }
    
        ul>li:nth-of-type(3)>span {
          background-position-x: -200%;
        }
    
        ul>li:nth-of-type(4)>span {
          background-position-x: -300%;
        }
    
        ul>li:nth-of-type(5)>span {
          background-position-x: -400%;
        }
    
        .pre,
        .next {
          width: 40px;
          height: 60px;
          font-size: 40px;
          position: absolute;
          top: 50%;
          text-decoration: none;
          text-align: center;
          line-height: 60px;
          color: #ccc;
          background-color: rgba(0, 0, 0, 0.4);
          transform: translate(0, -50%);
        }
    
        .pre {
          left: 0;
        }
    
        .next {
          right: 0;
        }
      </style>
    </head>
    
    <body>
      <div class="view">
        <ul>
          <li>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
    
          </li>
          <li>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
    
          </li>
          <li>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
    
          </li>
          <li>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
          </li>
          <li>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
          </li>
        </ul>
        <a href="javascript:;" class="pre" id="pre">&lt;</a>
        <a href="javascript:;" class="next" id="next">&gt;</a>
      </div>
      <script src="./js/jquery-3.1.0.js"></script>
      <script>
        $(function () {
          var index = 0
          var flag = true;
          //右箭头
          $("#next").on("click", function () {
            if (flag == true) {
              flag = false;
              index--;
              $("li").each(function (key, value) {
                $(this).css({
                  "transform": "rotateX(" + (index * 90) + "deg)",
                  "transition-delay": (key * 0.2) + "s"
                });
              });
              setTimeout(function () {
                flag = true;
              }, 1000);
            }
          });
          //左箭头
          $("#pre").on("click", function () {
            if (flag == true) {
              flag = false;
              index++;
              $("li").each(function (key, value) {
                $(this).css({
                  "transform": "rotateX(" + (index * 90) + "deg)",
                  "transition-delay": (key * 0.2) + "s"
                });
              });
              setTimeout(function () {
                flag = true;
              }, 1000)
            }
          })
    
    
        })
      </script>
    </body>
    
    </html>

  • 相关阅读:
    C++中 结构体和类的异同
    c++sizeof大全
    10th week task -3 Arrow function restore
    10th week task -2 Object 的起源
    js 的起源故事
    10th week task -1
    9th week -the history of program 1950~2020
    javascript统计一个字符在一段字符串出现次数
    Grid layout
    BOM DOM区别 来源
  • 原文地址:https://www.cnblogs.com/tuziling/p/10072323.html
Copyright © 2011-2022 走看看