小视频软件开发,实现一个CSS边框动画

小视频软件开发,实现一个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边框动画, 更多内容欢迎关注之后的文章

posted @ 2024-11-02 09:15  云豹科技-苏凌霄  阅读(3)  评论(0编辑  收藏  举报