为你的Butterfly添加顶部加载进度条
Dome
4.5.0 版本
4.5.0 版本主题已内置 pace.js 无需再次引入,在 hexo-theme-butterfly
文件中配置以下内容即可
preloader:
enable: true
# source
# 1. fullpage-loading
# 2. pace (progress bar)
source: 2
# pace theme (see https://codebyzach.github.io/pace/)
pace_css_url: https://fastly.jsdelivr.net/gh/xlenco/JS-X@main/pace.js/pace.css
如果你同时在使用 Heo同款loading动画,请查看
Heo同款loading动
4.5.0 版本以下
引入 css
.pace {
pointer-events: none;
user-select: none;
z-index: 2;
position: fixed;
margin: auto;
top: 4px;
left: 0;
right: 0;
height: 8px;
border-radius: 8px;
width: 6rem;
background: #eaecf2;
overflow: hidden;
}
.pace-inactive .pace-progress {
opacity: 0;
transition: 0.3s ease-in;
}
.pace.pace-inactive {
opacity: 0;
transition: 0.3s;
top: -8px;
}
.pace .pace-progress {
box-sizing: border-box;
transform: translate3d(0, 0, 0);
position: fixed;
z-index: 2;
display: block;
position: absolute;
top: 0;
right: 100%;
height: 100%;
width: 100%;
background: #49b1f5;
background: linear-gradient(
to right,
rgb(18, 194, 233),
rgb(196, 113, 237),
rgb(246, 79, 89)
);
animation: gradient 2s ease infinite;
background-size: 200%;
}
引入 JS
<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
然后三连即可
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Xlenco!
评论