视差滚动

<!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>
      html,
      body {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
      }
      .img {
        width: 100%;
        height: 75%;
        color: #fff;
        font-size: 100px;
        display: flex;
        justify-content: center;
        align-items: center;

        background-size: cover;
        background-attachment: fixed;
        background-position: center;
        /* background-repeat: no-repeat; */

        box-sizing: border-box;
        border: 10px solid #000;
      }
      .img:nth-child(1) {
        background-image: url("./img/img1.jpg");
      }
      .img:nth-child(2) {
        background-image: url("./img/img2.jpg");
      }
      .img:nth-child(3) {
        background-image: url("./img/img3.jpg");
      }
      .img:nth-child(4) {
        background-image: url("./img/img4.jpg");
      }
      .img:nth-child(5) {
        background-image: url("./img/img5.jpg");
      }
      .img:nth-child(6) {
        background-image: url("./img/img6.jpg");
      }
    </style>
  </head>
  <body>
    <div class="img">IMG1</div>
    <div class="img">IMG2</div>
    <div class="img">IMG3</div>
    <div class="img">IMG4</div>
    <div class="img">IMG5</div>
    <div class="img">IMG6</div>
    <script></script>
  </body>
</html>

posted @ 2020-06-13 10:40  彭尼玛  阅读(113)  评论(0编辑  收藏  举报