如何利用HTML5实现等待加载动画的效果


本文摘自PHP中文网,作者巴扎黑,侵删。

详细代码如下所示:

1

2

3

<p class="loading">

     <p>100<span></span></p>

</p>

1

2

3

4

5

6

7

8

9

10

*{margin:0;padding:0;}

  .loading{

        height:100%;width:100%;position:fixed;background:rgba(255,255,255,1);

  }

  .loading >p{position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;height:160px;width:160px;text-align: center;line-height:160px;font-size: 30px;color:#f00;}

  .loading p span{position:absolute;display:block;height:140px;width:140px;margin:10px;border-radius:50%;-webkit-box-shadow:0 2px 3px rgba(102,197,37,0.8); animation:loading ease 1s infinite;left:0;top:0;}

  @keyframes loading{

     0%{transform:rotate(0deg)}

     100%{transform:rotate(360deg)}

  }

1

2

3

4

5

6

7

8

9

<p class="loading">

     <p>

  <i></i>

  <i></i>

  <i></i>

  <i></i>

  <i></i>

</p>

</p>

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

*{margin:0;padding:0;}

    .loading{

          height:100%;width:100%;position:fixed;background:rgba(255,255,255,0.95);

    }

    .loading >p{position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;height:30px;width:120px;}

    .loading >p i{display: block;float:left;margin:0 5px; width:5px;height:30px;background:#f00;transform:scaleY(0.3);

                   animation:loading 1s ease infinite alternate;

    }

.loading >p i:nth-child(2){animation-delay:0.1s;}

.loading >p i:nth-child(3){animation-delay:0.2s;}

.loading >p i:nth-child(4){animation-delay:0.3s;}

.loading >p i:nth-child(5){animation-delay:0.4s;}

    @keyframes loading{

           0,40%,100%{transform:scaleY(0.3);}

           20%{transform:scaleY(1);}

    }

阅读剩余部分

相关阅读 >>

HTML5表单相关元素和属性

HTML5新增标签有哪些

h5的地理定位怎样使用

浅谈HTML5和html4之间的不同

详细介绍websocket api HTML5规范翻译

HTML5 canvas画布详解(一)

h5在canvas中实现自定义路径动画

详细介绍HTML5实现3d迷宫的代码案例

HTML5中在元素滚动条在滚动时触发的事件onscroll

关于老式浏览器兼容HTML5和css3的问题详解

更多相关阅读请进入《HTML5》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...