我是靠谱客的博主 灵巧狗,这篇文章主要介绍漂亮实用的loading(加载)封装,现在分享给大家,希望可以做个参考。

要做一个异步登录,打算给用户做一点提示,所以就网上找了点代码,自己修改新增了一些,做了一个html+css+js的功能封装,以备未来直接使用。

html

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
<!-- 缓冲提示条 --> <div class='buffer hidden' id='buffer' > <div class="spinner"> <span class='buffer_tip' id='buffer_tip' >正在登陆</span> <div class="rect1"></div> <div class="rect2"></div> <div class="rect3"></div> <div class="rect4"></div> <div class="rect5"></div> </div> </div> <!-- 缓冲提示条 -->

css

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*缓冲提示条 start*/ .buffer{ background-color: black; height: 120px; width: 60%; margin: auto; filter: alpha(Opacity=60); -moz-opacity: 0.6; opacity: 0.85; border-radius: 7px; } .buffer_tip{ color: wheat; font-size: 20px; display: block; padding-top: 15px; } .spinner { margin: -190% auto; height: 60px; text-align: center; font-size: 10px; } .spinner > div { background-color: #67CF22; height: 100%; width: 6px; display: inline-block; -webkit-animation: stretchdelay 1.2s infinite ease-in-out; animation: stretchdelay 1.2s infinite ease-in-out; } .spinner .rect2 { -webkit-animation-delay: -1.1s; animation-delay: -1.1s; } .spinner .rect3 { -webkit-animation-delay: -1.0s; animation-delay: -1.0s; } .spinner .rect4 { -webkit-animation-delay: -0.9s; animation-delay: -0.9s; } .spinner .rect5 { -webkit-animation-delay: -0.8s; animation-delay: -0.8s; } @-webkit-keyframes stretchdelay { 0%, 40%, 100% { -webkit-transform: scaleY(0.4) } 20% { -webkit-transform: scaleY(1.0) } } @keyframes stretchdelay { 0%, 40%, 100% { transform: scaleY(0.4); -webkit-transform: scaleY(0.4); } 20% { transform: scaleY(1.0); -webkit-transform: scaleY(1.0); } } /*缓冲提示条 end*/


js

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*缓冲进度条 start*/ /** * 显示loading(加载)动画 * @param {[type]} tip_text [提示的文字] * @return {[type]} [description] */ function buffer_tip_show(tip_text){ $("#buffer_tip").html(tip_text ? tip_text : '请稍等'); $("#buffer").removeClass("hidden"); } /** * 不显示loading(加载)动画 * @return {[type]} [description] */ function buffer_tip_hidden(){ $("#buffer").addClass("hidden"); } /*缓冲进度条 end*/

如果要显示或者不显示动画,直接调用js函数就可以啦

复制代码
1
2
3
4
// 显示 buffer_tip_show('正在努力加载中'); // 不显示 buffer_tip_hidden();

动画效果无法截图额,将就看下


最后

以上就是灵巧狗最近收集整理的关于漂亮实用的loading(加载)封装的全部内容,更多相关漂亮实用内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(68)

评论列表共有 0 条评论

立即
投稿
返回
顶部