可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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?
回答1:
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.

回答2:
I couldn't get the selected answer to work but after a bit of research, I found that the horizontal scrolling div must have white-space: nowrap
in the css.
Here's complete working code:
Something
回答3:
overflow-x: scroll; overflow-y: hidden;
EDIT:
It works for me:
回答4:
for Horizontal scroll keep these two properties in mind:
overflow-x:scroll; white-space: nowrap;
See working link : click me
HTML
overflow:scroll
You can use the overflow property when you want to have better control of the layout. The default value is visible.You can use the overflow property when you want to have better control of the layout. The default value is visible.
CSS
div.scroll { background-color:#00FFFF; height:40px; overflow-x:scroll; white-space: nowrap; }