繁体   English   中英

如何始终在 div 上显示垂直滚动条

[英]How to always show the vertical scroll bar on div

无论高度如何,我都想始终在 div 上显示垂直滚动条。

 .myclass { overflow-y: scroll; }
 <div class="myclass"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div>

但是滚动条被禁用。 这是我的 JSFiddle: https ://jsfiddle.net/9jgp5ncm/

如何始终显示垂直滚动条。 请帮忙。

您尝试更改浏览器行为,这在本机滚动条上是不可能的。

您可以在 myClass diff 中添加一个内部 div 并使其比外部 diff 大 5 个像素,以便激活滚动元素。

或者使用数千个库之一来自定义滚动条。

但老实说,我不知道你为什么要为你的项目改变它。

您应该为容器添加高度:

.myclass
{
  overflow-y: scroll;
  height: 200px;
}

暂无
暂无

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

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