WordPress主题添加页面加载进度条
pace.js是一个非常赞的JavaScript插件,可以实时监听页面的数据加载,包括Ajax请求,显示页面加载进度,并且能够定制样式。
下面以WordPress默认主题Twenty Seventeen为例,将这个特效功能加到主题中。
首先下载:pace.js
将pace.min.js放到主题中引用。
将样式代码,添加到主题style.css最后:
.pace {
-webkit-pointer-events: none;
pointer-events: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-transition: opacity 0.8s ease-in-out;
-moz-transition: opacity 0.8s ease-in-out;
-o-transition: opacity 0.8s ease-in-out;
transition: opacity 0.8s ease-in-out;
}
.pace-inactive {
opacity: 0;
filter: alpha(opacity=0);
}
.pace .pace-progress {
background: #3690cf;
position: fixed;
z-index: 2000;
top: 0;
rightright: 100%;
width: 100%;
height: 2px;
}
版权声明
感谢作者分享.
感谢作者分享.
感谢分享