「HTML+CSS」自定義加載動(dòng)畫【029】
效果展示

Demo代碼
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<section><span></span></section>
</body>
</html>
CSS
html,body{
margin: 0;
height: 100%;
}
body{
display: flex;
justify-content: center;
align-items: center;
background: #263238;
}
section {
width: 650px;
height: 300px;
padding: 10px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid red;
}
span {
width : 96px;
height: 96px;
background: white;
border-radius: 50%;
animation: animloader 1s ease-in infinite;
}
@keyframes animloader {
0% { transform: scale(0); opacity: 1;}
100% { transform: scale(1); opacity: 0;}
}
原理詳解
步驟1
使用span標(biāo)簽,設(shè)置
寬度、高度均為96px 背景色:白色
width : 96px;
height: 96px;
background: white;
效果圖如下

步驟2
span圓角化
border-radius: 50%;
效果圖如下

步驟3
為span設(shè)置動(dòng)畫
初始狀態(tài):大小為0(相對(duì)于原大?。?,顏色為(白,透明級(jí)別1) 終止?fàn)顟B(tài):大小為1(相對(duì)于原大?。?,顏色為(白,透明級(jí)別0)
animation: animloader 1s ease-in infinite;
@keyframes animloader {
0% { transform: scale(0); opacity: 1;}
100% { transform: scale(1); opacity: 0;}
}
效果圖如下

結(jié)語
學(xué)習(xí)來源:
?https://codepen.io/bhadupranjal/pen/vYLZYqQ
文章僅作為學(xué)習(xí)筆記,記錄從0到1的一個(gè)過程。
希望對(duì)您有所幫助,如有錯(cuò)誤歡迎小伙伴指正~
我是 海轟?(?ˊ?ˋ)?
如果您覺得寫得可以的話請(qǐng)點(diǎn)個(gè)贊吧
謝謝支持??
評(píng)論
圖片
表情
