css 环绕动画

2021-12-01  本文已影响0人  雪纳瑞的哈士奇
<div  class="item">
            <div class="items"></div>
</div>
// 转动的边框线(两条)
.item {
  --bRadius: 10px;
  .items {
    position: relative;
    transition: all 0.3s;
    &::before,
    &::after {
      content: "";
      position: absolute;
      top: 16px;
      left: 16px;
      right: 16px;
      bottom: 3px;
      border: 2px solid #ff0000;
      transition: all 1.5s;
      border-radius: var(--bRadius);
      -webkit-animation: clippath 8s infinite linear;
      animation: clippath 8s infinite linear;
    }
    &::after {
      animation: clippath 8s infinite -4s linear;
    }
    @keyframes clippath {
      0%,
      100% {
        clip-path: inset(0 0 98% 0);
      }
      25% {
        clip-path: inset(0 98% 0 0);
      }
      50% {
        clip-path: inset(98% 0 0 0);
      }
      75% {
        clip-path: inset(0 0 0 98%);
      }
    }
  }
}
上一篇 下一篇

猜你喜欢

热点阅读