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部分
/*进度条CSS www.qyblog.cn*/ #load { background-color: #ff6651; height: 3px; width: 0px; position: fixed; left: 0px; top: 0px; z-index: 9999; }
阅读全文
评论前必须登录!
立即登录 注册