<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=\, initial-scale=1.0">
<title>Document</title>
<style>
.Index {
display: flex;
justify-content: center;
padding-top: 100px;
}
.box {
width: 200px;
margin: 200px auto 0px;
background: rebeccapurple;
position: relative;
line-height: 30px;
padding: 0 20px;
color: #fff;
border-radius: 5px;
}
.box::before,
.box::after {
content: "";
border: 1px solid;
border-image: linear-gradient(45deg, gold, deeppink) 1;
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
display: none;
}
.box:hover::after{
animation: clippath 3s infinite;
display: block;
}
.box:hover::before {
display: block;
animation: clippath 3s infinite -1.5s linear;
}
@keyframes clippath {
0%,
100% {
clip-path: inset(0 0 96% 0);
filter: hue-rotate(0deg);
}
25% {
clip-path: inset(0 96% 0 0);
}
50% {
clip-path: inset(96% 0 0 0);
filter: hue-rotate(360deg);
}
75% {
clip-path: inset(0 0 0 96%);
}
}
</style>
</head>
<body>
<div className="Index">
<div class="box">clip-path: inset 的神奇特效</div>
</div>
</body>
</html>