HTML5+CSS3小實(shí)例:簡單又好看的加載動畫效果

HTML5+CSS3做一個簡單又好看的加載動畫效果,一個三色圓環(huán)轉(zhuǎn)動,再加圓環(huán)內(nèi)部文字轉(zhuǎn)動,效果雖然簡單,但第一次看到還是很驚艷的,最主要一點(diǎn),代碼真的超簡單的。

效果:

源碼:

<!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>好看的加載動畫效果</title>
    <link rel="stylesheet" href="../css/16.css">
</head>

<body>
    <div class="loading">
        <span>拼命加載中</span>
    </div>
</body>

</html>
*{
    /* 初始化 取消頁面內(nèi)外邊距 */
    margin: 0;
    padding: 0;
}
body{
    /* 100%窗口高度 */
    height: 100vh;
    background: linear-gradient(to bottom,#2b5876,#09203f);
    /* 彈性布局 水平、垂直居中 */
    display: flex;
    justify-content: center;
    align-items: center;
}
.loading{
    width: 200px;
    height: 200px;
    box-sizing: border-box;
    border-radius: 50%;
    border-top: 10px solid #63A69F;
    /* 相對定位 */
    position: relative;    
    /* 執(zhí)行動畫:動畫a1 時長 線性的 無限次播放 */
    animation: a1 2s linear infinite;
}
.loading::before,.loading::after{
    content: "";
    width: 200px;
    height: 200px;
    /* 絕對定位 */
    position: absolute;
    left: 0;
    top: -10px;
    box-sizing: border-box;
    border-radius: 50%;
}
.loading::before{
    border-top: 10px solid #F2E1AC;
    /* 旋轉(zhuǎn)120度 */
    transform: rotate(120deg);
}
.loading::after{   
    border-top: 10px solid #F2836B;
    /* 旋轉(zhuǎn)240度 */
    transform: rotate(240deg);
}
.loading span{
    /* 絕對定位 */
    position: absolute;
    width: 200px;
    height: 200px;
    line-height: 200px;
    text-align: center;
    color: #fff;
    /* 執(zhí)行動畫:動畫a2 時長 線性的 無限次播放 */
    animation: a2 2s linear infinite;
}
/* 定義動畫 */
@keyframes a1{
    to{
        transform: rotate(360deg);
    }
}
@keyframes a2{
    to{
        transform: rotate(-360deg);
    }
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

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

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