• 全屏滚动


    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>全屏滚动</title>
        <link rel="stylesheet" href="./main.css" />
      </head>
      <body>
        <nav>
          <div class="nav_item" data-index="0">导航1</div>
          <div class="nav_item" data-index="1">导航2</div>
          <div class="nav_item" data-index="2">导航3</div>
          <div class="nav_item" data-index="3">导航4</div>
          <div class="nav_item" data-index="4">导航5</div>
        </nav>
        <main>
          <div class="content">内容1</div>
          <div class="content">内容2</div>
          <div class="content">内容3</div>
          <div class="content">内容4</div>
          <div class="content">内容5</div>
        </main>
    
        <script>
          let $nav = document.querySelector("nav");
          let $main = document.querySelector("main");
          let currIndex = 0;
          $nav.children[currIndex].classList.add("active");
    
          $nav.addEventListener("click", function (e) {
            this.children[currIndex].classList.remove("active");
            e.target.classList.add("active");
            currIndex = e.target.dataset.index;
    
            // main移动,overflow让body来做
            $main.style.transform = `translateY(-${currIndex * 100}%)`;
          });
        </script>
      </body>
    </html>
    
    html,
    body {
      margin: 0;
      padding: 0;
       100%;
      height: 100%;
      overflow: hidden;
    }
    
    nav {
      position: fixed;
      bottom: 0;
      display: flex;
      align-items: center;
       100%;
      z-index: 2;
    }
    
    .nav_item {
      position: relative;
      flex: 1;
      line-height: 40px;
      text-align: center;
      background-color: #f55;
      font-size: 24px;
      color: #fff;
    }
    
    .nav_item:hover {
      background-color: rgba(85, 85, 255, 0.5);
    }
    
    .nav_item::after {
      content: "";
      position: absolute;
      top: 0;
      left: 50%;
      -webkit-transform: translate(-50%, -100%);
              transform: translate(-50%, -100%);
      border: 20px solid transparent;
      border-bottom-color: #55f;
      display: none;
    }
    
    .nav_item.active {
      background-color: #55f;
    }
    
    .nav_item.active::after {
      display: inline-block;
    }
    
    main {
      height: 100%;
      transition: all 0.5s;
    }
    
    .content {
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 100px;
    }
    
    
  • 相关阅读:
    C# 冒泡排序
    C# IO流 File.Exists,Directory.Exists, File.Create,Directory.CreateDirectory
    UGUI 哪些显示在前方的问题
    UGUI Image血条或者进度条效果
    Unity 切换场景的时候让某个游戏对象不消失
    C# string型的转换成float型的
    Json 解析Json
    logging模块

    模块和包
  • 原文地址:https://www.cnblogs.com/pengnima/p/13111972.html
Copyright © 2020-2023  润新知