HTML5+CSS3小实例:冒泡loading动画

实例:冒泡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>纯CSS实现冒泡loading动画</title>
    <link rel="stylesheet" href="../css/95.css">
</head>
 
<body>
    <div class="loader">
        <div class="box">
            <div class="circle"></div>
            <div class="circle"></div>
        </div>
        <span>Loading...</span>
    </div>
</body>
 
</html>

【css】

*{
    /* 初始化 */
    margin: 0;
    padding: 0;
    /* box-sizing: border-box; */
}
body{
    /* 100%窗口高度 */
    height: 100vh;
    /* 弹性布局 水平+垂直居中 */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #333;
}
.loader{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.loader .box{
    /* 相对定位 */
    position: relative;
    width: 200px;
    height: 200px;
    /* 执行动画:动画名 时长 线性的 无限次播放 */
    animation: rotateBox 10s linear infinite;
}
.loader .box .circle{
    /* 绝对定位 */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #F5E866;
    border-radius: 50%;
    /* 执行动画:动画名 时长 线性的 无限次播放 */
    animation: animate 5s linear infinite;
}
.loader .box .circle:nth-child(2){
    background-color: #A08FD5;
    /* 设置第二个圆的动画延迟时间 */
    animation-delay: -2.5s;
}
.loader span{
    margin-top: 30px;
    font-size: 20px;
    font-weight: 400;
    color: #fff;
    letter-spacing: 4px;
}
 
/* 定义动画 */
@keyframes animate {
    0%{
        transform: scale(1);
        transform-origin: left;
    }
    50%{
        transform: scale(0);
        transform-origin: left;
    }
    50.01%{
        transform: scale(0);
        transform-origin: right;
    }
    100%{
        transform: scale(1);
        transform-origin: right;
    }
}
@keyframes rotateBox {
    to{
        transform: rotate(360deg);
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容