简体   繁体   English

如何使div的滚动条始终可见?

[英]How do I make a div’s scrollbar always visible?

How do I make my div 's scrollbar always visible? 如何使div的滚动条始终可见?

.el {
  height: 100px;
  overflow: scroll;
  position: relative;
}

overflow: scroll is not working. overflow: scroll不起作用。 It seems my browser's native behavior does not allow that. 看来我的浏览器的本机行为不允许这样做。 (I'm on macOS.) (我在macOS上。)

Is there some workaround? 有一些解决方法吗?

PS The scroll bar is visible on hover, but I need it to always be visible. PS滚动条在悬停时可见,但我需要使其始终可见。

You could try 你可以试试

html {
  height: 101%;
}

It's a browser issue, the browser have there own style for these elements. 这是浏览器的问题,浏览器对这些元素有自己的风格。

If scrollbar go to hidden, it's for the user comfort, you can't change this... 如果滚动条变为隐藏状态,是为了使用户感到舒适,则不能更改此设置...

So you can try to make div scrollable with custom scrollbar plugin in jQuery for example : 因此,您可以尝试使用jQuery中的自定义滚动条插件使div可滚动,例如:

https://github.com/gromo/jquery.scrollbar https://github.com/gromo/jquery.scrollbar

This plugin create fake scrollbars in javascript and permit to user to scroll into element. 该插件在javascript中创建伪造的滚动条,并允许用户滚动到element中。 So browser don't apply his own rules for these scrollbar because they aren't. 因此,浏览器不要对这些滚动条应用自己的规则,因为事实并非如此。

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

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