學習心得
1、模糊語法:filter:blur(20px); 此代碼直接設置模糊度
2、設置完background:linear-gradient() 漸變色后 再加上一個background-size, 最后加上個相反的size就能實現顏色的漸變動畫。
3、偽元素 上下左右分別給個-5px,能實現大於本體的一點,效果堪稱棒!
CSS
* {
margin: 0;
padding: 0;
}
body {
background-color: #000;
}
a {
text-decoration: none;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
background: linear-gradient(90deg, #03a9f4, #f441a5, #03a9f4);
background-size: 400%;
width: 400px;
height: 100px;
color: white;
text-align: center;
line-height: 100px;
text-transform: uppercase;
border-radius: 50px;
}
a:hover::before {
animation: sun 8s infinite;
}
a::before {
content: "";
position: absolute;
left: -5px;
right: -5px;
top: -5px;
bottom: -5px;
/* border: 1px solid red; */
background: linear-gradient(90deg, #03a9f4, #f441a5, #03a9f4);
background-size: 400%;
border-radius: 50px;
filter: blur(20px);
z-index: -1;
}
@keyframes sun {
100% {
background-position: -400% 0;
}
}
HTML
HTML一個a標簽足以
<a href="">sunbutton</a>