HTML5+CSS3小實例:莫比烏斯環(huán)loading動畫

實例:莫比烏斯環(huán)loading動畫
技術棧: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)loading動畫</title>
    <link rel="stylesheet" href="../css/85.css">
</head>
 
<body>
    <div class="loader">
        <div class="lt">
            <div></div>
        </div>
        <div class="lb">
            <div></div>
        </div>
        <div class="rt">
            <div></div>
        </div>
        <div class="rb">
            <div></div>
        </div>
    </div>
</body>
 
</html>

【css】

*{
    /* 初始化 */
    margin: 0;
    padding: 0;
}
body{
    /* 100%窗口高度 */
    height: 100vh;
    /* 彈性布局 水平+垂直居中 */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #333;
}
.loader{
    display: flex;
    justify-content: center;
    align-items: center;
    /* 相對定位 */
    position: relative;
    left: 15px;
}
.loader::before,
.loader::after{
    content: "";
    width: 150px;
    height: 150px;
    border-radius: 50%;
    box-sizing: border-box;
    border: 15px solid #57606f;
    position: relative;
    z-index: -1;
}
.loader::after{
    left: -15px;
}
.loader div{
    width: 150px;
    height: 150px;
    /* 絕對定位 */
    position: absolute;
    left: 0;
    /* 利用clip-path的方式遮蓋掉下半部分 */
    clip-path: polygon(0 0,100% 0,100% 50%,0 50%);
}
.loader div div{
    width: 150px;
    height: 150px;
    box-sizing: border-box;
    border-style: solid;
    border-width: 15px;
    border-color: #ff6b81 #ff6b81 transparent transparent;
    border-radius: 50%;
    position: absolute;
    /* 默認旋轉135度,讓圓環(huán)處于遮蓋處 */
    transform: rotate(135deg);
    /* 執(zhí)行動畫:動畫名 時長 線性 無限播放 */
    animation: roll 4s linear infinite;
}
.rt,.rb{
    transform: translateX(calc(100% - 15px));
}
.lb{
    transform: scale(-1,-1);
}
.rt{
    transform: translateX(calc(100% - 15px)) scale(-1,1);
}
.rb{
    transform: translateX(calc(100% - 15px)) scale(1,-1);
}
/* 設置動畫延遲 */
.loader .rb div{
    animation-delay: 1s;
}
.loader .rt div{
    animation-delay: 2s;
}
.loader .lb div{
    animation-delay: 3s;
}
 
/* 定義動畫 */
@keyframes roll {
    50%,100%{
        transform: rotate(495deg);
    }
}
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容