首先看一下Wordpress的模板在浏览器中的载入顺序

根据原理可以有下图的实现方法

要做改动的文件有6个,分别为header.php、index.php、single.php、sidebar.php、footer.php、style.css
①header.php
在body下加入如下代码:
- <div id="awloading">
- <div id="awlfull">
- </div>
- <div id="awlpercent">
- </div>
- <div id="awlt">
- 正在加载...
- </div>
- </div>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
②index.php、single.php
加入如下代码:
- <script type="text/javascript">$("#awlpercent").animate({"width":"40px"});</script>
③sidebar.php
加入如下代码:
- <script type="text/javascript">$("#awlpercent").animate({"width":"94px"});</script>
④footer.php
加入如下代码
- <script type="text/javascript">
- $("#awlpercent").animate({"width":"100px"});
- setTimeout(function(){$("#awloading").hide(460)},1000);
- </script>
⑤style.css
加入如下代码
- /* Loading */
- #awloading {z-index:1;left:0;top:0;position:fixed}
- #awloading div {position:absolute}
- #awlfull, #awlpercent {-moz-border-radius-bottomright:5px;height:28px;-webkit-border-bottom-right-radius:5px;opacity:.6}
- #awlfull {background:#ECC779;width:100px}
- #awlpercent {background:#c44;width:6px;}
- #awlt {font-size:16px;z-index:2;width:100px;color:#fff;padding:5px 0 5px 9px}
学习至阿瓦,配图出处不详…