跳至主要內容

按钮缩放

HeChuangJun约 227 字小于 1 分钟

按钮缩放

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>按钮缩放</title>
    <style>
      * { margin: 0; padding: 0; }
      li { list-style: none; }
      img { width: 100%; }
      .box { width: 249px; height: 210px; margin: 50px auto; }
      .box p { color: #3b3b3b;padding: 10px 10px 0 10px;}
      /* 1. 摆放播放按钮:图片区域的中间 */
      .box li { overflow: hidden; }
      .pic { position: relative; }
      .pic::after {
        position: absolute;
        left: 50%;
        top: 50%;

        content: '';
        width: 58px;
        height: 58px;
        background-image: url(./images/play.png);
        /* margin-left: -29px; margin-top: -29px; */
        transform: translate(-50%, -50%) scale(5);
        opacity: 0;
        transition: all .5s;
      }
      /* 2. hover效果:大按钮,看不见:透明是0 → 小按钮,看得见:透明度1 */
      .box li:hover .pic::after {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <ul>
        <li>
          <div class="pic">
            <img src="./images/party.jpeg" alt="" />
          </div>
          <p>【和平精英】“初火”音乐概念片:四圣觉醒......</p>
        </li>
      </ul>
    </div>
  </body>
</html>