• 简易web-slide


    <!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>
      <link rel="stylesheet" href="./index.css">
    </head>
    <body>
      <div class="container">
        <div class="slide" id="1">1</div>
        <div class="slide" id="2">2</div>
        <div class="slide" id="3">3</div>
        <div class="slide" id="4">4</div>
        <div class="slide" id="5">5</div>
        <div class="slide" id="6">6</div>
      </div>
      <script src="./a.js"></script>
    </body>
    </html>
    
    .container {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      overflow: hidden;
    }
    .slide {
       100%;
      height: 100%;
      font-size: 50px;
      text-align: center;
    }
    @keyframes zoomIn {
      from {
        opacity: 0;
        -webkit-transform: scale3d(0.3, 0.3, 0.3);
        transform: scale3d(0.3, 0.3, 0.3);
      }
    
      50% {
        opacity: 1;
      }
    }
    
    .zoomIn {
      animation: zoomIn 0.5s;
    }
    
    let num = 1;
    let total = 6;
    function page(num) {
      window.location.hash = '#' + num;
      document.getElementById(num).classList.toggle('zoomIn');
      setTimeout(() => {
        document.getElementById(num).classList.toggle('zoomIn');
      }, 500);
    }
    function prev() {
      if (num <= 1) {
        return
      }
      num -= 1;
      page(num);
    }
    function next() {
      if (num >= total) {
        return
      }
      num += 1;
      page(num);
    }
    window.addEventListener('keydown', (e) => {
      // console.log(e);
      if (e.code === 'ArrowDown' || e.code === 'ArrowRight') {
        next();
      }
      if (e.code === 'ArrowUp' || e.code === 'ArrowLeft') {
        prev();
      }
    });
    
  • 相关阅读:
    Leetcode
    287. Find the Duplicate Number hard
    House Robber III leetcode 动态规划
    将一个数组分成奇数部分和偶数部分,并分别排好序 CVTE
    First Missing Positive && missing number
    permutation II (boss出来了)
    46. Permutations 回溯算法
    字符串分割 函数实现
    Combination Sum II Combinations
    用双缓存技术优化listview异步加载网络图片
  • 原文地址:https://www.cnblogs.com/dkplus/p/8986894.html
Copyright © 2020-2023  润新知