炫彩的按鈕漸變動畫——css3
阿新 • • 發佈:2021-01-18
炫彩的按鈕漸變動畫——css3
效果(是動態的):
程式碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title >
<style>
* {
margin: 0;
padding: 0;
}
body {
background: #000;
}
.light-btn {
text-decoration: none;
position: absolute;
left: 50%;
top:50%;
transform: translate(-50%, -50%);
font-size: 24px;
background: linear-gradient(90deg, #ff9933, #ff5500, #ff0a01, #ff9933);
background-size : 400%;
width: 400px;
height: 100px;
line-height:100px;
color: #fff;
text-align: center;
text-transform: uppercase;
border-radius: 50px;
z-index: 1;
}
.light-btn:hover::before,
.light-btn:hover {
animation: sun 4s infinite;
}
.light-btn::before {
content: '';
position: absolute;
left : -5px;
right: -5px;
top: -5px;
bottom: -5px;
background: linear-gradient(90deg, #ff9933, #ff5500, #ff0a01, #ff9933);
background-size: 400%;
border-radius: 50px;
filter: blur(10px);
z-index: -1;
}
@keyframes sun {
100%{
background-position: -400% 0;
}
}
</style>
</head>
<body>
<button class="light-btn">button</button>
</body>
</html>
貼上即用!