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>滚动的方块loading动画</title>
    <link rel="stylesheet" href="../css/77.css">
</head>
 
<body>
    <div class="loader">
        <div class="square"></div>
        <div class="text">
            <p>拼命加载中...</p>
        </div>
    </div>
</body>
 
</html>

【css】

*{
    /* 初始化 */
    margin: 0;
    padding: 0;
}
body{
    /* 100%窗口高度 */
    height: 100vh;
    /* 弹性布局 水平+垂直居中 */
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}
.loader{
    /* 相对定位 */
    position: relative;
}
.square{
    width: 200px;
    height: 200px;
    background: #48c0a3;
    /* 阴影 外发光效果 */
    box-shadow: 0 0 15px #48c0a3,
    0 0 30px #48c0a3,
    0 0 60px #48c0a3;
    /* 设置旋转元素的基点位置 */
    transform-origin: bottom right;
    /* 执行动画:动画名 时长 线性 无限次播放 */
    animation: roll 1s linear infinite;
}
/* 黑色遮罩(挖空正方形) */
.square::before{
    content: "";
    width: 150px;
    height: 150px;
    /* 绝对定位 居中 */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    background: #000;
    /* 阴影 内发光 */
    box-shadow: inset 0 0 15px #48c0a3,
    inset 0 0 30px #48c0a3,
    inset 0 0 60px #48c0a3;
}
.text{
    width: 300px;
    height: 40px;
    line-height: 40px;
    position: absolute;
    left: -40px;
    bottom: -80px;
    /* 溢出隐藏 */
    overflow: hidden;
}
.text p{
    color: #48c0a3;
    font-size: 24px;
    white-space: nowrap;
    /* 文字发光 */
    text-shadow: 0 0 2px #48c0a3,
    0 0 4px #48c0a3,
    0 0 8px #48c0a3;
    position: absolute;
    /* 默认移出可视范围 */
    left: 100%;
    /* 执行动画 */
    animation: move 3.5s linear infinite;
}
 
/* 定义动画 */
/* 方形翻转动画 */
@keyframes roll {
    100%{
        transform: translateX(-100%) rotateZ(90deg);
    }
}
/* 文本移动动画 */
@keyframes move {
    100%{
        left: -50%;
    }
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容