css 蛇型边框

<!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>
    <link rel="stylesheet" type="text/css" href="index.css">
</head>

<body>
    <div class="conic"></div>
    <div class="conic conic-demo"></div>
 <style>
    body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #000;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

@-webkit-keyframes rotate {
  100% {
    transform: rotate(1turn);
  }
}

@keyframes rotate {
  100% {
    transform: rotate(1turn);
  }
}
.conic {
  position: relative;
  z-index: 0;
  width: 400px;
  height: 300px;
  margin: 20px;
  border: 1px solid #ccc;
  border-radius: 10px;
  overflow: hidden;
  padding: 2rem;
}
.conic::before {
  content: "";
  position: absolute;
  z-index: -2;
  left: -50%;
  top: -50%;
  width: 200%;
  height: 200%;
  background-color: #000;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-image: conic-gradient(transparent, #a8efff, transparent 10%);
  -webkit-animation: rotate 4s linear infinite;
          animation: rotate 4s linear infinite;
}
.conic::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 6px;
  top: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  background: #000;
  border-radius: 5px;
}

.conic-demo::after {
  -webkit-animation: opacityChange 5s infinite linear;
          animation: opacityChange 5s infinite linear;
}

@-webkit-keyframes opacityChange {
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

@keyframes opacityChange {
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}
 </style>
</body>

</html>

posted @   7c89  阅读(33)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
历史上的今天:
2022-03-20 new FileReader()
点击右上角即可分享
微信分享提示