为了加强浏览者的体验,不在等待页面加载时感到枯燥,从而关闭网页,很多网站都会制作一个“网页正在加载中”的提示效果或显示加载进程,加载完成后提示消失,大部分都应用在网站的首页,今天我教大家把这一特效添加到Emlog主题中。要实现该特效同样要用到jquery,如果大家和我目前用的主题一样,为了实现其它特效已提前加载了jquery,那么正好充分利用jquery的强大功能,添加此特效何乐而不为呢?当然仅仅为了实现这个特效,而去加载50几K的jquery就有点得不偿失了。
) Q, Z* U8 d* l/ I4 B) C% n; q1.首先在</body>之前加上如下代码:- <div id="circle"></div>. k. E* U. N3 U% H' J( {# H
- <div id="circletext"></div>' `' z7 c; v" ]8 o1 o
- <div id="circle1"></div>
复制代码 # q0 ~4 u. {; y, X
7 t- [! G) `" A
2.再加上一段JS- <script type="text/javascript">" p- x5 y: J1 ~9 N# ~0 n2 t
- $(function () {* }: r2 N* Z- U9 W3 h/ U, |& n# r* Q
- $("#circletext").text("加载肿");+ g; z1 ]" s* h! n( l% I) ]- i
- $(window).load(function() {
. z, f- ^6 `( L4 s9 q - $("#circle").fadeOut(400);
8 d( O" |4 M+ P8 Z8 H: ? - $("#circle1").fadeOut(600);( B2 e: J7 ]7 I. y( W
- $("#circletext").text("完成鸟").fadeOut(800);
/ b6 q% R' @, K8 j0 Z - });
* N! i! v7 x, B0 a - });
, ~2 E0 |4 T8 o. h - //-->
, T1 j# R$ h' [' u4 w) J - </script>
复制代码 @# a" u/ h- C Y, D9 i; Z* ]! g
$ A9 `5 ~$ |5 z8 c/ W! v# i6 \
3.加上CSS- /* 圆圈加载*/3 R+ Z$ V8 e3 _0 C6 J4 T* u" v
- #circle{background-color:rgba(0,0,0,0);border:5px solid rgba(10,10,10,0.9);opacity:.9;border-right:5px solid rgba6 X7 z( j2 Z( v6 M" p) ?0 B: f$ r# v& R
- (0,0,0,0);border-left:5px solid rgba(0,0,0,0);border-radius:50px;box-shadow:0 0 35px #808080;width:60px;height:60px;margin:0 auto;position:fixed;left:30px;bottom:30px;-moz-animation:spinPulse 1s infinite linear;-webkit-animation:spinPulse 1s infinite linear;-o-animation:spinPulse 1s infinite linear;-ms-animation:spinPulse 1s infinite linear;}) s( l' i; L2 N+ o/ K- o% \
- #circle1{background-color:rgba(0,0,0,0);border:6px solid rgba(20,20,20,0.9);opacity:.9;border-left:6px solid rgba(0,0,0,0);border-right:6px solid rgba(0,0,0,0);border-radius:50px;box-shadow:0 0 15px #202020;width:40px;height:40px;margin:0 auto;position:fixed;left:39px;bottom:39px;-moz-animation:spinoffPulse 1s infinite linear;-webkit-animation:spinoffPulse 1s infinite linear;-o-animation:spinoffPulse 1s infinite linear;-ms-animation:spinoffPulse 1s infinite linear;}
+ O* p7 n, ?7 r3 x8 ?& F" g - #circletext{width:46px;height:20px;margin:0 auto;position:fixed;left:46px;bottom:53px;}
1 R# Z- G3 b# V - @-moz-keyframes spinPulse{0%{-moz-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050;}50%{-moz-transform:rotate(145deg);opacity:1;}100%{-moz-transform:rotate(-320deg);opacity:0;}}
. \5 Y1 J! e4 U( m+ K; v9 w* U0 L - @-moz-keyframes spinoffPulse{0%{-moz-transform:rotate(0deg);}100%{-moz-transform:rotate(360deg);}}
. P* `3 P$ l$ \1 w0 W. o+ y - @-webkit-keyframes spinPulse{0%{-webkit-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050;}50%{-webkit-transform:rotate(145deg);opacity:1;}100%{-webkit-transform:rotate(-320deg);opacity:0;}}/ `) c4 W- f3 x, x( r: l8 K
- @-webkit-keyframes spinoffPulse{0%{-webkit-transform:rotate(0deg);}100%{-webkit-transform:rotate(360deg);}}
0 b/ m7 h3 ~/ I8 T* Q- J - @-o-keyframes spinPulse{0%{-o-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050;}50%{-o-transform:rotate(145deg);opacity:1;}100%{-o-transform:rotate(-320deg);opacity:0;}}$ ~5 r2 w8 {9 R& Y+ F
- @-o-keyframes spinoffPulse{0%{-o-transform:rotate(0deg);}100%{-o-transform:rotate(360deg);}}" _5 R: \! |; h" m2 W, ^
- @-ms-keyframes spinPulse{0%{-ms-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050;}50%{-ms-transform:rotate(145deg);opacity:1;}100%{-ms-transform:rotate(-320deg);opacity:0;}}: F2 i1 {* D! J% o. }
- @-ms-keyframes spinoffPulse{0%{-ms-transform:rotate(0deg);}100%{-ms-transform:rotate(360deg);}}
复制代码 就是这么简单的,效果:
9 ?' P& [. u$ W c0 } |