仅具有水平滚动功能的 Div [英] Div with horizontal scrolling only
问题描述
我有一个固定宽度的 DIV,其中包含一个包含多列的表格,并且需要允许用户在 DIV 内水平滚动表格.
这只需要在 IE6 和 IE7 上工作(内部客户端应用程序).
以下在 IE7 中有效:
overflow-x:滚动;
谁能帮忙提供一个也适用于 IE6 的解决方案?
解决方案相当简单.为了确保我们不会影响表格中单元格的宽度,我们将关闭空白.为了确保我们得到一个水平滚动条,我们将打开 overflow-x.差不多就是这样:
.container {宽度:30em;溢出-x:自动;空白:nowrap;}
您可以在
I have a fixed width DIV containing a table with many columns, and need to allow the user to scroll the table horizontally within the DIV.
This needs to work on IE6 and IE7 only (internal client application).
The following works in IE7:
overflow-x: scroll;
Can anyone help with a solution that works in IE6 as well?
The solution is fairly straight forward. To ensure that we don't impact the width of the cells in the table, we'll turn off white-space. To ensure we get a horizontal scroll bar, we'll turn on overflow-x. And that's pretty much it:
.container {
width: 30em;
overflow-x: auto;
white-space: nowrap;
}
You can see the end-result here, or in the animation below. If the table determines the height of your container, you should not need to explicitly set overflow-y
to hidden
. But understand that is also an option.
这篇关于仅具有水平滚动功能的 Div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!