官网地址:http://github.hubspot.com/pace/docs/welcome/
使用教程
一、加载js
在主题页眉(header.php)的<head></head>之间引入js
- <script src="https://raw.github.com/HubSpot/pace/v1.0.0/pace.min.js"></script>
#你也可以把这个js文件下载下来,比如将这个js文件存放在网站根目录,那么就这样引入:
- <script src="https://static.imtrq.com(网站域名)/pace.min.js"></script>
二、加载css
1 获取CSS代码
先去官网选择一种颜色和样式
我这里选择灰色,样式我就选择一个loading bar,点击copy to clipboard
这样我就把这个css代码复制到剪切板了
2 引入CSS代码
有两种方法
方法一:
在上一步说的<head></head>标签之间加入一段代码
- <style>
- .pace {
- -webkit-pointer-events: none;
- pointer-events: none;
- -webkit-user-select: none;
- -moz-user-select: none;
- user-select: none;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- -ms-box-sizing: border-box;
- -o-box-sizing: border-box;
- box-sizing: border-box;
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
- -webkit-background-clip: padding-box;
- -moz-background-clip: padding;
- background-clip: padding-box;
- z-index: 2000;
- position: fixed;
- margin: auto;
- top: 12px;
- left: 0;
- rightright: 0;
- bottombottom: 0;
- width: 200px;
- height: 50px;
- overflow: hidden;
- }
- .pace .pace-progress {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- -ms-box-sizing: border-box;
- -o-box-sizing: border-box;
- box-sizing: border-box;
- -webkit-border-radius: 2px;
- -moz-border-radius: 2px;
- border-radius: 2px;
- -webkit-background-clip: padding-box;
- -moz-background-clip: padding;
- background-clip: padding-box;
- -webkit-transform: translate3d(0, 0, 0);
- transform: translate3d(0, 0, 0);
- display: block;
- position: absolute;
- rightright: 100%;
- margin-right: -7px;
- width: 93%;
- top: 7px;
- height: 14px;
- font-size: 12px;
- background: #aaaaaa;
- color: #aaaaaa;
- line-height: 60px;
- font-weight: bold;
- font-family: Helvetica, Arial, "Lucida Grande", sans-serif;
- -webkit-box-shadow: 120px 0 #fff, 240px 0 #fff;
- -ms-box-shadow: 120px 0 #fff, 240px 0 #fff;
- box-shadow: 120px 0 #fff, 240px 0 #fff;
- }
- .pace .pace-progress:after {
- content: attr(data-progress-text);
- display: inline-block;
- position: fixed;
- width: 45px;
- text-align: rightright;
- rightright: 0;
- padding-right: 16px;
- top: 4px;
- }
- .pace .pace-progress[data-progress-text="0%"]:after { rightright: -200px }
- .pace .pace-progress[data-progress-text="1%"]:after { rightright: -198.14px }
- .pace .pace-progress[data-progress-text="2%"]:after { rightright: -196.28px }
- .pace .pace-progress[data-progress-text="3%"]:after { rightright: -194.42px }
- .pace .pace-progress[data-progress-text="4%"]:after { rightright: -192.56px }
- .pace .pace-progress[data-progress-text="5%"]:after { rightright: -190.7px }
- .pace .pace-progress[data-progress-text="6%"]:after { rightright: -188.84px }
- .pace .pace-progress[data-progress-text="7%"]:after { rightright: -186.98px }
- .pace .pace-progress[data-progress-text="8%"]:after { rightright: -185.12px }
- .pace .pace-progress[data-progress-text="9%"]:after { rightright: -183.26px }
- .pace .pace-progress[data-progress-text="10%"]:after { rightright: -181.4px }
- .pace .pace-progress[data-progress-text="11%"]:after { rightright: -179.54px }
- .pace .pace-progress[data-progress-text="12%"]:after { rightright: -177.68px }
- .pace .pace-progress[data-progress-text="13%"]:after { rightright: -175.82px }
- .pace .pace-progress[data-progress-text="14%"]:after { rightright: -173.96px }
- .pace .pace-progress[data-progress-text="15%"]:after { rightright: -172.1px }
- .pace .pace-progress[data-progress-text="16%"]:after { rightright: -170.24px }
- .pace .pace-progress[data-progress-text="17%"]:after { rightright: -168.38px }
- .pace .pace-progress[data-progress-text="18%"]:after { rightright: -166.52px }
- .pace .pace-progress[data-progress-text="19%"]:after { rightright: -164.66px }
- .pace .pace-progress[data-progress-text="20%"]:after { rightright: -162.8px }
- .pace .pace-progress[data-progress-text="21%"]:after { rightright: -160.94px }
- .pace .pace-progress[data-progress-text="22%"]:after { rightright: -159.08px }
- .pace .pace-progress[data-progress-text="23%"]:after { rightright: -157.22px }
- .pace .pace-progress[data-progress-text="24%"]:after { rightright: -155.36px }
- .pace .pace-progress[data-progress-text="25%"]:after { rightright: -153.5px }
- .pace .pace-progress[data-progress-text="26%"]:after { rightright: -151.64px }
- .pace .pace-progress[data-progress-text="27%"]:after { rightright: -149.78px }
- .pace .pace-progress[data-progress-text="28%"]:after { rightright: -147.92px }
- .pace .pace-progress[data-progress-text="29%"]:after { rightright: -146.06px }
- .pace .pace-progress[data-progress-text="30%"]:after { rightright: -144.2px }
- .pace .pace-progress[data-progress-text="31%"]:after { rightright: -142.34px }
- .pace .pace-progress[data-progress-text="32%"]:after { rightright: -140.48px }
- .pace .pace-progress[data-progress-text="33%"]:after { rightright: -138.62px }
- .pace .pace-progress[data-progress-text="34%"]:after { rightright: -136.76px }
- .pace .pace-progress[data-progress-text="35%"]:after { rightright: -134.9px }
- .pace .pace-progress[data-progress-text="36%"]:after { rightright: -133.04px }
- .pace .pace-progress[data-progress-text="37%"]:after { rightright: -131.18px }
- .pace .pace-progress[data-progress-text="38%"]:after { rightright: -129.32px }
- .pace .pace-progress[data-progress-text="39%"]:after { rightright: -127.46px }
- .pace .pace-progress[data-progress-text="40%"]:after { rightright: -125.6px }
- .pace .pace-progress[data-progress-text="41%"]:after { rightright: -123.74px }
- .pace .pace-progress[data-progress-text="42%"]:after { rightright: -121.88px }
- .pace .pace-progress[data-progress-text="43%"]:after { rightright: -120.02px }
- .pace .pace-progress[data-progress-text="44%"]:after { rightright: -118.16px }
- .pace .pace-progress[data-progress-text="45%"]:after { rightright: -116.3px }
- .pace .pace-progress[data-progress-text="46%"]:after { rightright: -114.44px }
- .pace .pace-progress[data-progress-text="47%"]:after { rightright: -112.58px }
- .pace .pace-progress[data-progress-text="48%"]:after { rightright: -110.72px }
- .pace .pace-progress[data-progress-text="49%"]:after { rightright: -108.86px }
- .pace .pace-progress[data-progress-text="50%"]:after { rightright: -107px }
- .pace .pace-progress[data-progress-text="51%"]:after { rightright: -105.14px }
- .pace .pace-progress[data-progress-text="52%"]:after { rightright: -103.28px }
- .pace .pace-progress[data-progress-text="53%"]:after { rightright: -101.42px }
- .pace .pace-progress[data-progress-text="54%"]:after { rightright: -99.56px }
- .pace .pace-progress[data-progress-text="55%"]:after { rightright: -97.7px }
- .pace .pace-progress[data-progress-text="56%"]:after { rightright: -95.84px }
- .pace .pace-progress[data-progress-text="57%"]:after { rightright: -93.98px }
- .pace .pace-progress[data-progress-text="58%"]:after { rightright: -92.12px }
- .pace .pace-progress[data-progress-text="59%"]:after { rightright: -90.26px }
- .pace .pace-progress[data-progress-text="60%"]:after { rightright: -88.4px }
- .pace .pace-progress[data-progress-text="61%"]:after { rightright: -86.53999999999999px }
- .pace .pace-progress[data-progress-text="62%"]:after { rightright: -84.68px }
- .pace .pace-progress[data-progress-text="63%"]:after { rightright: -82.82px }
- .pace .pace-progress[data-progress-text="64%"]:after { rightright: -80.96000000000001px }
- .pace .pace-progress[data-progress-text="65%"]:after { rightright: -79.1px }
- .pace .pace-progress[data-progress-text="66%"]:after { rightright: -77.24px }
- .pace .pace-progress[data-progress-text="67%"]:after { rightright: -75.38px }
- .pace .pace-progress[data-progress-text="68%"]:after { rightright: -73.52px }
- .pace .pace-progress[data-progress-text="69%"]:after { rightright: -71.66px }
- .pace .pace-progress[data-progress-text="70%"]:after { rightright: -69.8px }
- .pace .pace-progress[data-progress-text="71%"]:after { rightright: -67.94px }
- .pace .pace-progress[data-progress-text="72%"]:after { rightright: -66.08px }
- .pace .pace-progress[data-progress-text="73%"]:after { rightright: -64.22px }
- .pace .pace-progress[data-progress-text="74%"]:after { rightright: -62.36px }
- .pace .pace-progress[data-progress-text="75%"]:after { rightright: -60.5px }
- .pace .pace-progress[data-progress-text="76%"]:after { rightright: -58.64px }
- .pace .pace-progress[data-progress-text="77%"]:after { rightright: -56.78px }
- .pace .pace-progress[data-progress-text="78%"]:after { rightright: -54.92px }
- .pace .pace-progress[data-progress-text="79%"]:after { rightright: -53.06px }
- .pace .pace-progress[data-progress-text="80%"]:after { rightright: -51.2px }
- .pace .pace-progress[data-progress-text="81%"]:after { rightright: -49.34px }
- .pace .pace-progress[data-progress-text="82%"]:after { rightright: -47.480000000000004px }
- .pace .pace-progress[data-progress-text="83%"]:after { rightright: -45.62px }
- .pace .pace-progress[data-progress-text="84%"]:after { rightright: -43.76px }
- .pace .pace-progress[data-progress-text="85%"]:after { rightright: -41.9px }
- .pace .pace-progress[data-progress-text="86%"]:after { rightright: -40.04px }
- .pace .pace-progress[data-progress-text="87%"]:after { rightright: -38.18px }
- .pace .pace-progress[data-progress-text="88%"]:after { rightright: -36.32px }
- .pace .pace-progress[data-progress-text="89%"]:after { rightright: -34.46px }
- .pace .pace-progress[data-progress-text="90%"]:after { rightright: -32.6px }
- .pace .pace-progress[data-progress-text="91%"]:after { rightright: -30.740000000000002px }
- .pace .pace-progress[data-progress-text="92%"]:after { rightright: -28.880000000000003px }
- .pace .pace-progress[data-progress-text="93%"]:after { rightright: -27.02px }
- .pace .pace-progress[data-progress-text="94%"]:after { rightright: -25.16px }
- .pace .pace-progress[data-progress-text="95%"]:after { rightright: -23.3px }
- .pace .pace-progress[data-progress-text="96%"]:after { rightright: -21.439999999999998px }
- .pace .pace-progress[data-progress-text="97%"]:after { rightright: -19.58px }
- .pace .pace-progress[data-progress-text="98%"]:after { rightright: -17.72px }
- .pace .pace-progress[data-progress-text="99%"]:after { rightright: -15.86px }
- .pace .pace-progress[data-progress-text="100%"]:after { rightright: -14px }
- .pace .pace-activity {
- position: absolute;
- width: 100%;
- height: 28px;
- z-index: 2001;
- box-shadow: inset 0 0 0 2px #aaaaaa, inset 0 0 0 7px #FFF;
- border-radius: 10px;
- }
- .pace.pace-inactive {
- display: none;
- }
- </style>
<style>标签中的那一长串就是刚刚复制的CSS代码。
方法二:
把刚刚复制的CSS代码粘贴到一个空白文件中,比如说我粘贴到一个pace.css中,并且放在网站的/wp-content/themes
目录,那么我只需要这样引入:
- <link href="https://static.imtrq.com/wp-content/themes/pace.css" rel="stylesheet"/>
访问一下网站查看效果(最好使用无痕模式)。
Comments | NOTHING