今天教大家一个在你WordPress网站访问有点慢时,可以提高用户体验的纯CSS「加载中」动画
插件(插件)版
一、添加CSS动画代码
1、这是最主要的一个步骤,用处时来显示加载中的动画
2、把下列代码添加到你主题的「样式表 (style.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 73 74 75 76 77  | 
						/** 「载入中」动画 **/ #circle { 	background-color: rgba(0,0,0,0); 	border:5px solid rgba(10,10,10,0.9); 	opacity:.9; 	border-right:5px solid rgba(0,0,0,0); 	border-left:5px solid rgba(0,0,0,0); 	border-radius:50px; 	box-shadow: 0 0 35px #808080; 	z-index:1000; 	width:50px; 	height:50px; 		margin:0 auto;	    	position:fixed; 		left:30px; 		bottom:30px; 	-moz-animation:spinPulse 1s infinite ease-in-out; 	-webkit-animation:spinPulse 1s infinite ease-in-out; 	-o-animation:spinPulse 1s infinite ease-in-out; 	-ms-animation:spinPulse 1s infinite ease-in-out; } #circle1 { 	background-color: rgba(0,0,0,0); 	border:5px solid rgba(20,20,20,0.9); 	opacity:.9; 	border-left:5px solid rgba(0,0,0,0); 	border-right:5px solid rgba(0,0,0,0); 	border-radius:50px; 	box-shadow: 0 0 15px #202020;  	z-index:1000; 	width:30px; 	height:30px; 		margin:0 auto; 		position:fixed; 		left:40px; 		bottom:40px; 	-moz-animation:spinoffPulse 1s infinite linear; 	-webkit-animation:spinoffPulse 1s infinite linear; 	-o-animation:spinoffPulse 1s infinite linear; 	-ms-animation:spinoffPulse 1s infinite linear; } @-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; } } @-moz-keyframes spinoffPulse { 	0% { -moz-transform:rotate(0deg); } 	100% { -moz-transform:rotate(360deg);  } } @-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; } } @-webkit-keyframes spinoffPulse { 	0% { -webkit-transform:rotate(0deg); } 	100% { -webkit-transform:rotate(360deg); } } @-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; } } @-o-keyframes spinoffPulse { 	0% { -o-transform:rotate(0deg); } 	100% { -o-transform:rotate(360deg); } } @-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; } } @-ms-keyframes spinoffPulse { 	0% { -ms-transform:rotate(0deg); } 	100% { -ms-transform:rotate(360deg); } }  | 
					
二、添加显示代码
1、这一步的用处是把前面的CSS代码显示出来
2、在主题内的「页首 (header.php)」文件的 <body> 后同样添加下列代码
| 
					 1  | 
						<div id="circle"></div><div id="circle1"></div>  | 
					
三、添加jQuery渐隐效果
1、这个步骤是用于在网页加载完成后是加载动画渐渐消失,而不是一直不停地转动
2、在「页尾 (footer.php)」内的 </body> 前添加下列代码就完咯
| 
					 1 2 3 4 5 6  | 
						<script> jQuery(window).load(function() { 	jQuery("#circle").fadeOut(500); 	jQuery("#circle1").fadeOut(700); }); </script>  | 
					
预览
本页左下角会永远旋转「加载中」动画
参考
总结
1、完成以上步骤后要清空快取才能显示效果 ![]()
2、有问题可以回复 ![]()
