index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>流光按钮</title>
<link rel="stylesheet" href="../css/index.css">
</head>
<body>
<a href="javascript:;">流光按钮</a>
</body>
</html>
index.css
*{
margin:0;
padding: 0;
}
body{
background: #000;
}
a{
text-decoration: none;
position:absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
/* 上面这句不懂 */
font-size: 24px;
background: linear-gradient(90deg,blue,purple,red,yellow,blue);
background-size: 400%;
width: 400px;
height: 100px;
line-height: 100px;
text-align: center;
color: white;
border-radius: 50px;
}
a::before{
content: "";
position: absolute;
left: -5px;
right: -5px;
top: -5px;
bottom: -5px;
background: linear-gradient(90deg,blue,purple,red,yellow,blue);
background-size: 400%;
border-radius: 50px;
filter: blur(20px);
z-index: -1;
}
a:hover::before{
animation: flow 8s infinite;
}
a:hover{
animation: flow 8s infinite;
z-index: 1;
}
@keyframes flow{
100%{
background-position: -400% 0;
}
}
实现效果
css实现流光按钮(用于优快云视频存放)
参考:https://www.bilibili.com/video/BV1cK4y1k7qG