小影片軟體開發,實現一個CSS邊框動畫

云豹科技-苏凌霄發表於2024-11-02

小影片軟體開發,實現一個CSS邊框動畫

<!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>
    * {
      margin: 0;
      padding: 0;
      list-style: none;
      --transition-duration: 500ms;
    }

    .box {
      width: 500px;
      height: 300px;
      background-color: #000;
      padding: 10px;
      position: relative;
    }

    .box::before {
      position: absolute;
      content: '';
      display: inline-block;
      top: 10px;
      left: 10px;
      width: 0;
      height: 1px;
      background-color: #fff;
      transition: all ease var(--transition-duration);
      transition-delay: 0s;
    }

    .box::after {
      position: absolute;
      content: '';
      display: inline-block;
      bottom: 10px;
      left: 10px;
      width: 0;
      height: 1px;
      background-color: #fff;
      transition: all ease var(--transition-duration);
      transition-delay: calc(var(--transition-duration)/1.25);
    }

    .box div {
      width: 100%;
      height: 100%;
      position: relative;
    }

    .content::before {
      position: absolute;
      content: '';
      display: inline-block;
      bottom: 0;
      left: 0;
      width: 1px;
      height: 0;
      background-color: #fff;
      transition: all ease var(--transition-duration);
      transition-delay: calc(var(--transition-duration)/1.25);
    }

    .content::after {
      position: absolute;
      content: '';
      display: inline-block;
      bottom: 0;
      right: 0;
      width: 1px;
      height: 0;
      background-color: #fff;
      transition: all ease var(--transition-duration);
      transition-delay: 0s;
    }

    .box:hover::after,
    .box:hover::before {
      width: 500px;
    }

    .content:hover::after,
    .content:hover::before {
      height: 100%;
    }

    .box:hover::before,
    .content:hover::after {
      transition-delay: calc(var(--transition-duration)/1.25);
    }

    .box:hover::after,
    .content:hover::before {
      transition-delay: 0s;
    }
  </style>
</head>

<body>
  <div class="box">
    <div class="content">
    </div>
  </div>
</body>

</html>

以上就是小影片軟體開發,實現一個CSS邊框動畫, 更多內容歡迎關注之後的文章

相關文章