• css | js 实现扩展卡片小demo


    1.代码如下

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link rel="stylesheet" href="./style.css" />
        <title>Document</title>
        <style>
          * {
            box-sizing: border-box;
          }
    
          body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
          }
          .container {
            display: flex;
            width: 90vw;
          }
          .panle {
            background-size: auto, 100%;
            background-position: center;
            background-repeat: no-repeat;
            border-radius: 50px;
            color: #fff;
            flex: 0.5;
            cursor: pointer;
            height: 80vh;
            position: relative;
            margin: 10px;
            transition: flex 0.7s cubic-bezier(0.05, 0.6, 0.4, 0.9);
          }
          .panle h3 {
            font-size: 24px;
            opacity: 0;
            position: absolute;
            bottom: 20px;
            left: 20px;
            margin: 0;
            transition: opacity 0s ease-in 0s;
          }
          .panle.active {
            flex: 5;
          }
          .panle.active h3 {
            opacity: 1;
            transition: opacity 0.3s ease-in 0.4s;
          }
          @media (max-width: 500px) {
            .container {
              width: 100vw;
            }
            .panle:nth-of-type(4) {
              display: none;
            }
            .panle:nth-of-type(5) {
              display: none;
            }
          }
        </style>
      </head>
      <body>
        <div class="container">
          <div class="panle" style="background-image: url(./img/img1.jpg);">
            <h3>海阔天空</h3>
          </div>
          <div class="panle" style="background-image: url(./img/img2.jpg);">
            <h3>蓝天白云</h3>
          </div>
          <div class="panle" style="background-image: url(./img/img3.jpg);">
            <h3>山川湖海</h3>
          </div>
          <div class="panle" style="background-image: url(./img/img4.jpg);">
            <h3>星空灿烂</h3>
          </div>
          <div class="panle" style="background-image: url(./img/img5.jpg);">
            <h3>绿树成荫</h3>
          </div>
        </div>
    
        <script>
          const penles = document.querySelectorAll(".panle");
          penles.forEach((panle) => {
            panle.addEventListener("click", () => {
              removeClass();
              panle.classList.add("active");
            });
            function removeClass() {
              penles.forEach((penle) => {
                penle.classList.remove("active");
              });
            }
          });
        </script>
      </body>
    </html>
    
    

    2.效果展示

    在这里插入图片描述
    在这里插入图片描述

    3.使用资源图片如下

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    -------------完成!!!!!!!

  • 相关阅读:
    《Twinkle Twinkle Little Star》
    《牛客IOI周赛24-普及组B》
    You have to remove (or rename) that container to be able to reuse that name.
    MySQL查看服务器状态、数据库、表的命令
    【用户不在sudoers文件中】的两种解决方式
    Ubuntu20.04安装Docker时摊上的那些事儿
    Ubuntu20.04安装Docker以后设置阿里云镜像加速
    Ubuntu20.04默认更新源sources.list和第三方源推荐(干货!)
    Ubuntu必备软件之搜狗输入法
    Ubuntu20.04必备软件之截图工具
  • 原文地址:https://www.cnblogs.com/jackson1/p/12682663.html
Copyright © 2020-2023  润新知