HTML5+CSS3小實例:酷炫的環(huán)形加載動畫

實例:酷炫的環(huán)形加載動畫
技術(shù)棧:HTML+CSS
效果:

源碼:
【html】

<!DOCTYPE html>
<html>
 
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
 
    <title>酷炫的環(huán)形加載動畫</title>
    <link rel="stylesheet" href="../css/55.css">
</head>
 
<body>
    <div class="container">
        <div class="circle"></div>
        <div class="circle"></div>
        <div class="circle"></div>
    </div>
</body>
 
</html>

【css】

*{
    /* 初始化 */
    margin: 0;
    padding: 0;
}
body{
    /* 100%窗口高度 */
    height: 100vh;
    /* 彈性布局 居中 */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}
.container{
    /* 相對定位 */
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.container .circle{
    position: relative;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 5px solid transparent;
    margin: -30px;
    /* 通過var函數(shù)調(diào)用自定義屬性--c(顏色值) */
    border-top: 5px solid var(--c);
    /* 通過var函數(shù)調(diào)用自定義屬性--a(動畫名) */
    /* 執(zhí)行動畫:動畫名 時長 線性的 無限次播放 */
    animation: var(--a) 3s linear infinite;
}
/* 發(fā)光頭 */
.container .circle::before{
    content: "";
    /* 絕對定位 */
    position: absolute;
    top: 12px;
    right: 12px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: var(--c);
    /* 陰影(發(fā)光效果) */
    box-shadow: 
    0 0 5px var(--c),
    0 0 10px var(--c),
    0 0 20px var(--c),
    0 0 40px var(--c),
    0 0 80px var(--c);
}
/* 第三個圓 */
.container .circle:nth-child(3){
    position: absolute;
    top: -66.66px;
    /* 設(shè)置自定義屬性--c(顏色)、--a(動畫) */
    --c: lightgreen;
    --a: animate2;
    /* 動畫延遲時間 */
    animation-delay: -2s;
    /* 調(diào)整邊框 */
    border-top: 5px solid transparent;
    border-left: 5px solid var(--c);
}
/* 第二個圓 */
.container .circle:nth-child(2){
    --c: lightsalmon;
    --a: animate2;
    animation-delay: -0.5s;
    border-top: 5px solid transparent;
    border-left: 5px solid var(--c);
}
/* 第一個圓 */
.container .circle:nth-child(1){
    /* 設(shè)置自定義屬性--c(顏色)、--a(動畫) */
    --c: lightskyblue;
    --a: animate1;
}
.container .circle:nth-child(3):before,
.container .circle:nth-child(2):before{
    /* initial關(guān)鍵字用于設(shè)置CSS屬性為它的默認(rèn)值 */
    top: initial;
    left: 12px;
    bottom: 12px;
}
 
/* 定義動畫 */
@keyframes animate1 {
    0%{
        transform: rotate(0deg);
    }
    100%{
        transform: rotate(360deg);
    }
}
@keyframes animate2 {
    0%{
        transform: rotate(360deg);
    }
    100%{
        transform: rotate(0deg);
    }
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容