我试图在 DIV 上设置垂直滚动条以获得较短的高度。 它适用于 Chrome 和 IE 10(没有尝试其他)。 但是当高度太短时,Firefox 不会显示垂直滚动条。
有没有办法让 Firefox 显示垂直滚动条,即使高度很短?
div.title{
position: absolute;
top: 0px;
height: 97px;
width:100%;
}
body{
margin: 0;
}
div.tableHeader{
position: absolute;
top: 98px;
height: 28px;
overflow-y: scroll;
width:100%;
}
<body>
<div class="title">
<h1> Demo how to set vertical scroll bar</h1>
</div>
<div class="tableHeader">
<b>test vertical scroll bar, please check right side vertical scroll bar</b>
</div>
</body>
最佳答案
滚动条也出现在 Firefox 中,如果你想看到“可拖动条”,试试类似...
box-sizing: border-box;
padding: 6px 0;
..增加内部内容的高度。
div.tableHeader{
position: absolute;
top: 98px;
height: 28px;
overflow-y: scroll;
width:100%;
box-sizing: border-box;
padding: 8px 0;
}
<body>
<div class="tableHeader">
<b>test vertical scroll bar, please check right side vertical scroll bar</b>
</div>
</body>
关于css - 当高度太短时,Firefox 不显示垂直滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29497788/