小球形状的“loading”(在原文代码的基础上做的改造)

<!doctype html>
<html>
<head>
   <title>小球形状的loading</title>
    <style>
        /* general styling */
        /*.box {*/
            /*width:450px;*/
            /*margin:18px auto;*/
            /*background: red;*/
        /*}*/

        /* position the bars and balls correctly (rotate them and translate them outward)*/
        .bar1 {
            -moz-transform:rotate(0deg) translate(0, -40px);
            -webkit-transform:rotate(0deg) translate(0, -40px);opacity:0.12;
        }
        .bar2 {
            -moz-transform:rotate(45deg) translate(0, -40px);
            -webkit-transform:rotate(45deg) translate(0, -40px);opacity:0.25;
        }
        .bar3 {
            -moz-transform:rotate(90deg) translate(0, -40px);
            -webkit-transform:rotate(90deg) translate(0, -40px);opacity:0.37;
        }
        .bar4 {
            -moz-transform:rotate(135deg) translate(0, -40px);
            -webkit-transform:rotate(135deg) translate(0, -40px);opacity:0.50;
        }
        .bar5 {
            -moz-transform:rotate(180deg) translate(0, -40px);
            -webkit-transform:rotate(180deg) translate(0, -40px);opacity:0.62;
        }
        .bar6 {
            -moz-transform:rotate(225deg) translate(0, -40px);
            -webkit-transform:rotate(225deg) translate(0, -40px);opacity:0.75;
        }
        .bar7 {
            -moz-transform:rotate(270deg) translate(0, -40px);
            -webkit-transform:rotate(270deg) translate(0, -40px);opacity:0.87;
        }
        .bar8 {
            -moz-transform:rotate(315deg) translate(0, -40px);
            -webkit-transform:rotate(315deg) translate(0, -40px);opacity:1;
        }


        /* set up the three ball spinners */
        #div4 {
            position:relative;
            width:100px;
            height:100px;
            margin:25px;
            -moz-border-radius:100px;
            -webkit-border-radius:100px;
            float:left;
            -moz-transform:scale(0.5);
            -webkit-transform:scale(0.5);

            -webkit-animation-name: rotateThis;
            -webkit-animation-duration:2s;
            -webkit-animation-iteration-count:infinite;
            -webkit-animation-timing-function:linear;
        }
        #div4 div {
            width:20px;
            height:20px;
            background:#000;
            -moz-border-radius:40px;
            -webkit-border-radius:40px;
            position:absolute;
            left:40px;
            top:40px;
        }
        /* add a shadow to the first */
        #div4 div {
            -moz-box-shadow:black 0 0 4px;
            -webkit-box-shadow:black 0 0 4px;
        }


    </style>
    <script>

        //simple script to rotate all spinners 45 degrees on each tick
        //this works differently from the css transforms, which is smooth

        var count = 0;
        function rotate() {

            var elem4 = document.getElementById('div4');

            elem4.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';

            elem4.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';

            if (count==360) { count = 0 }
            count+=45;
            window.setTimeout(rotate, 100);
        }
        window.setTimeout(rotate, 100);
    </script>

</head>

<body>
<div class="box">
    <div id="div4">
        <div class="bar1"></div>
        <div class="bar2"></div>
        <div class="bar3"></div>
        <div class="bar4"></div>
        <div class="bar5"></div>
        <div class="bar6"></div>
        <div class="bar7"></div>
        <div class="bar8"></div>
    </div>
</div>




</body>

</html>

上述代码实现原文中第4个效果。(注:代码主要来自原作者,只在上面做了提取)


原文链接:

https://kilianvalkhof.com/uploads/spinners/



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值