2

I want to add div to my website which has variable width, and that it will display scroll bars when the width is smaller than the longest line. I tried wrapping such a fixed width element, in a variable width (100%) but that didn't work. I got the scroll bars on the entire page.

Any thoughts?

Thanks Yaron

4

1 回答 1

0

您可以将overflowCSS 属性应用于有问题的div

#problematic-div {
    overflow: hidden;
}

这定义了溢出元素内容区域的内容会发生什么。对于值滚动,用户代理应该提供滚动机制,不管它是否真的需要;因此,例如,即使所有内容都可以容纳在元素框内,也会出现滚动条。

您可以在这里尝试一些示例。

希望能帮助到你。

于 2011-08-24T13:40:52.927 回答