简体   繁体   English

让垂直滚动条始终显示css

[英]Have the vertical scroll bar always present css

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, ie 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? 是否有可能不仅显示滚动条而且还显示光标?

Make the html a bit higher and the scroll will show up 使html更高,滚动将显示

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? 您使用什么javascript /插件来实现无限滚动?

My gut instinct is that the infinite scroll may be happening in an element below the top-level html element. 我的直觉是无限滚动可能发生在顶级html元素下面的元素中。 Maybe try using your browser's developer's tools to identify which element is actually scrolling, and applying the "overflow-y: scroll;" 也许尝试使用浏览器的开发人员工具来识别实际滚动的元素,并应用“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. 如果系统从页面顶部删除旧元素以便不会耗尽内存,则滚动到滚动条顶部可能无法将您带到页面顶部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM