加载动画(纯css+h5)小特效案例

效果图如上:

代码如下:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>加载特效</title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
                /* 将border和padding计算到内容中 */
                box-sizing: border-box;
            }
            section{
                /* 弹性布局 */
                display: flex;
                /* 横向居中 */
                justify-content: center;
                /* 纵向居中 */
                align-items: center;
                /* 窗口最低高度 */
                min-height: 100vh;
                background: #000000;
                animation: animateBg 5s linear infinite;
            }
            section div{
                /* 相对定位 */
                position: relative;
                width: 120px;
                height: 120px;
            }
            section div span{
                /* 绝对定位 */
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                /* calc()函数 动态计算 var()获取style中的--i的值*/
                transform: rotate(calc(18deg * var(--i)));
            }
            section div span::before{
                content: "";
                position: absolute;
                top: 0;
                left: 0;
                width: 15px;
                height: 15px;
                border-radius: 50%;
                background: red;
                box-shadow: 0 0 10px red,0 0 20px red,0 0 40px red,0 0 60px red,0 0 70px red,0 0 100px red;
                animation: move 2s linear infinite;
                /* 让当前动画延时运行 */
                animation-delay: calc(0.1s * var(--i));
            }
            @keyframes move{
                0%{
                    transform: scale(1);
                }
                100%{
                    transform: scale(0);
                }
            }
            @keyframes animateBg{
                0%{
                    filter: hue-rotate(0deg);
                }
                100%{
                    filter: hue-rotate(360deg);
                }
            }
            section div p{
                color: #F0FFFF;
                margin-top: 50px;
                margin-left: 30px;
            }
        </style>
    </head>
    <body>
        <section>
            <div id="">
                <p>loading...</p>
            <span style="--i:1"></span>
            <span style="--i:2"></span>
            <span style="--i:3"></span>
            <span style="--i:4"></span>
            <span style="--i:5"></span>
            <span style="--i:6"></span>
            <span style="--i:7"></span>
            <span style="--i:8"></span>
            <span style="--i:9"></span>
            <span style="--i:10"></span>
            <span style="--i:11"></span>
            <span style="--i:12"></span>
            <span style="--i:13"></span>
            <span style="--i:14"></span>
            <span style="--i:15"></span>
            <span style="--i:16"></span>
            <span style="--i:17"></span>
            <span style="--i:18"></span>
            <span style="--i:19"></span>
            <span style="--i:20"></span>
            </div>
        </section>
    </body>
</html>

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值