Not many words, first effect:
Introduction:
Use basic css to make a cool streamer button, not just a button, as long as it is a box.
Specific steps:
1. First define a box as a button, such as I use a tag:
<body>
<a href="#" class="guang">button</a>
</body>
2. First write the basic styles for the a tag, such as length and width...:
.guang{
position: relative;
display: inline-block;
width: 220px;
height: 80px;
color: rgb(255, 255, 255);
line-height: 80px;
font-size: 35px;
font-family: sans-serif;
text-decoration: none;
text-transform: uppercase;
text-align: center;
border-radius: 30px;
background: linear-gradient(90deg,rgb(39, 122, 218),rgb(74, 230, 121),rgb(201, 214, 13),rgb(226, 20, 233),rgb(16, 172, 219));
background-size: 400%;
z-index: 1;
text-shadow: 0 0 5px white,
0 0 5px white;
}
Note: Some of these properties are useful:
text-transform: uppercase; All are replaced with uppercase letters.
background: linear-gradient(...); Linear color gradient, you can change it to the color you want.
text-shadow: 0 0 5px white,
0 0 5px white;
Two lines are written to make the font brighter.
3. The animation of the streamer generated by the mouse passing the box:
.guang:hover{
animation: move 5s linear alternate infinite;
}
@keyframes move{
0%{
background-position: 0%;
}
100%{
background-position: 100%;
}
}
4. Define the halo shadow around the box:
.guang::before{
content: '';
position: absolute;
top: -10px;
left: -10px;
width: 240px;
height: 100px;
background: linear-gradient(90deg,rgb(39, 122, 218),rgb(74, 230, 121),rgb(243, 169, 10),rgb(226, 20, 233),rgb(16, 172, 219));
background-size: 400%;
opacity: 0;
z-index: -1;
border-radius: 45px;
transition: 0.6s;
}
.guang:hover::before{
filter: blur(15px);
opacity: 1;
animation: move 8s linear alternate infinite;
}
Note: some of the properties are useful:
filter: blur filter, is to make it blur
Complete code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: black;
}
.guang{
position: relative;
display: inline-block;
width: 220px;
height: 80px;
color: rgb(255, 255, 255);
line-height: 80px;
font-size: 35px;
font-family: sans-serif;
text-decoration: none;
text-transform: uppercase;
text-align: center;
border-radius: 30px;
background: linear-gradient(90deg,rgb(39, 122, 218),rgb(74, 230, 121),rgb(201, 214, 13),rgb(226, 20, 233),rgb(16, 172, 219));
background-size: 400%;
z-index: 1;
text-shadow: 0 0 5px white,
0 0 5px white;
}
.guang:hover{
animation: move 5s linear alternate infinite;
}
@keyframes move{
0%{
background-position: 0%;
}
100%{
background-position: 100%;
}
}
.guang::before{
content: '';
position: absolute;
top: -10px;
left: -10px;
width: 240px;
height: 100px;
background: linear-gradient(90deg,rgb(39, 122, 218),rgb(74, 230, 121),rgb(243, 169, 10),rgb(226, 20, 233),rgb(16, 172, 219));
background-size: 400%;
opacity: 0;
z-index: -1;
border-radius: 45px;
transition: 0.6s;
}
.guang:hover::before{
filter: blur(15px);
opacity: 1;
animation: move 8s linear alternate infinite;
}
</style>
<body>
<a href="#" class="guang">button</a>
</body>
</html>
to sum up
Haha~