分享学习记录
互联网技术知识

网站美化教程:为网站添加一个横向进度条

JS代码

$(function() {
function scroll_fn(){
document_height = $(document).height();
scroll_so_far = $(window).scrollTop();
window_height = $(window).height();
max_scroll = document_height-window_height;
scroll_percentage = scroll_so_far/(max_scroll/100);
$('#load').width(scroll_percentage + '%');
}
$(window).scroll(function() {
scroll_fn();
});
$(window).resize(function() {
scroll_fn();
});
});

html部分

<div id="load"></div>

CSS部分

#load {
    background-color: #ff6651;
    height: 3px;
    width: 0px;
    position: fixed;
    left: 0px;
    top: 0px;
    z-index: 9999;
}
赞(0)
文章名称:《网站美化教程:为网站添加一个横向进度条》
文章链接:https://www.bailuze.com/6598.html
本站所有文章,如无特殊说明或标注,均为本站原创发布。任何在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
本站专注于百度、搜狗、360、谷歌、bing等常见搜索引擎的优化,关键词排名的提高,诚意咨询邮箱526009505@qq.com
分享到