Div with horizontal scrolling only

匿名 (未验证) 提交于 2019-12-03 08:30:34

问题:

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; } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!