最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Have the vertical scroll bar always present css - Stack Overflow

programmeradmin0浏览0评论

I have a web page with infinite scrolling. I always want to have the vertical scrollbar present so I have added the following style:

html {  
  overflow-y: scroll;   
}

This works in that it shows the scrollbar but it just displays an empty scrollbar, i.e. there is no cursor to allow the user to scroll up or down.

Is it possible to not only display the scrollbar but also have the cursor displaying as well?

I have a web page with infinite scrolling. I always want to have the vertical scrollbar present so I have added the following style:

html {  
  overflow-y: scroll;   
}

This works in that it shows the scrollbar but it just displays an empty scrollbar, i.e. there is no cursor to allow the user to scroll up or down.

Is it possible to not only display the scrollbar but also have the cursor displaying as well?

Share Improve this question edited Jul 3, 2012 at 13:50 John Conde 220k99 gold badges462 silver badges501 bronze badges asked Jul 3, 2012 at 13:49 dagda1dagda1 29k67 gold badges255 silver badges477 bronze badges 2
  • If the content doesn't scroll then the scroll bar will be empty. :P – uadnal Commented Jul 3, 2012 at 13:51
  • What do you mean by "infinite scrolling"? You have content that never ends? Normally, the cursor (I assume you mean the slider element that indicates where you are currently located within the element) will appear as soon as some of the content has overflowed the element on the specified axis. – AmericanUmlaut Commented Jul 3, 2012 at 13:53
Add a ment  | 

2 Answers 2

Reset to default 9

Make the html a bit higher and the scroll will show up

html {
   overflow-y: scroll;
   height: 101%
}

It's a bit hard to say with the limited information you've provided. What javascript/plugin are you using to achieve infinite scrolling?

My gut instinct is that the infinite scroll may be happening in an element below the top-level html element. Maybe try using your browser's developer's tools to identify which element is actually scrolling, and applying the "overflow-y: scroll;" to that.

Be warned, you may find that the reason they hide the vertical scroll-bar is that the plugin you're using makes it meaningless. If the system deletes old elements from the top of the page so as to not run out of memory, scrolling to the top of the scroll-bar may not take you to the top of the page.

发布评论

评论列表(0)

  1. 暂无评论