后台阅读进度虽然没有具体的用途,但是突然想起来,随便做也挺好的?可以通过获取元素偏移高度、元素高度、滑动距离来实现代码varcontent_offtop=$('.article-content').offset().top;varcontent_height=$('.article-content').innerHeight();$(window).scroll(function(){if(($(this).scrollTop()>content_offtop)){//滑动到内容部分if(($(this).scrollTop()-content_offtop)<=content_height){//滑入内容部分this.reading_p=Math.round(($(this).scrollTop()-content_offtop)/content_height*100);}else{//滑出内容部分this.reading_p=100;//确保进度条已满}}else{//不滑动到内容部分this.reading_p=0;//确保进度条不显示}$('.reading-bar').css('width',this.reading_p+'%');});↑JavaScript代码
