簡體   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