<a href="#">Button</a>
*{margin: 0;padding:0;}
body{
height: 100vh;width: 100vw;
display: flex;
justify-content: center;
align-items: center;
background: #000;
}
a{
padding: 12px 35px;
text-decoration: none;
font-size: 24px;
color: #fff;
border-radius: 20px;
background: linear-gradient(to right,#137fc7,#1862c2,#0be6e6,#0be654,#b7e60b,#137fc7);
background-size: 400%;
position: relative;
z-index: 1;
}
a:hover{
animation: show 8s linear infinite;
}
@keyframes show{
0%{
background-position: 0%;
}
100%{
background-position: 400%;
}
}
a::before{
position: absolute;
content: '';
background: linear-gradient(to right,#137fc7,#1862c2,#0be6e6,#0be654,#b7e60b,#137fc7);
background-size: 400%;
border-radius: 20px;
top:-5px;right:-5px;bottom:-5px;left:-5px;
filter: blur(12px);
opacity: 0;
z-index: -1;
}
a:hover::before{
opacity: 1;
animation: show 8s linear infinite;
}
案例来源:学习:用HTML&CSS实现炫彩流光按钮