「HTML+CSS」--自定義加載動畫【005】
Part1簡介
昵稱:海轟
標(biāo)簽:程序猿一只|C++選手|學(xué)生
簡介:因C語言結(jié)識編程,隨后轉(zhuǎn)入計算機專業(yè),有幸拿過國獎、省獎等,已保研。目前正在學(xué)習(xí)C++/Linux(真的真的太難了~)
學(xué)習(xí)經(jīng)驗:扎實基礎(chǔ) + 多做筆記 + 多敲代碼 + 多思考 + 學(xué)好英語!
Part2效果展示

Part3Demo代碼
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 class="loader-1"></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;
}
.loader-1 {
width : 96px;
height: 96px;
background: orange;
border: 10px solid #FFF;
border-bottom-color: #FF3D00;
border-radius: 50%;
display: inline-block;
animation: rotation 1s linear infinite;
}
@keyframes rotation {
0% { transform: rotate(0deg) }
100% { transform: rotate(360deg) }
}
Part4原理詳解
步驟1:生成一個邊長為96px的正方形
css代碼
width : 96px;
height: 96px;
background: orange;
效果圖如下


步驟2:設(shè)置該正方形的border
css代碼
border: 10px solid #FFF;
效果圖如下


注
橙色部分還是96px??96px,因為border寬度為10px,所以使得span實際大小為116??116px
步驟3:設(shè)置下邊框為紅色(重點?。?/span>
css代碼
border-bottom-color: #FF3D00;//設(shè)置下邊框顏色
效果圖如下

步驟4:設(shè)置border-radious=50%,將正方形變成圓形

步驟5:設(shè)置動畫,繞中心一直旋轉(zhuǎn)
css代碼
animation: rotation 1s linear infinite;
// 動畫實現(xiàn)
@keyframes rotation {
0% {
transform: rotate(0deg)
}
100% {
transform: rotate(360deg)
}
}
效果圖如下

Part5結(jié)語
學(xué)習(xí)來源:
https://codepen.io/bhadupranjal/pen/vYLZYqQ
文章僅作為學(xué)習(xí)筆記,記錄從0到1的一個過程。希望對您有所幫助,如有錯誤歡迎小伙伴指正~
Part6系列文章




我是海轟?(?ˊ?ˋ)?,如果您覺得寫得可以的話,請點個贊吧
寫作不易 「點贊」+「收藏」+「在看」
謝謝支持??

評論
圖片
表情
