一般容器 - IE8水平滚动条问题 [英] general container - IE8 horizontal scrollbar problem
问题描述
我遇到了以下问题:
如何创建一个通用容器(HTML + CSS;没有javascript)
垂直禁止(它有一个固定的外部高度) ,因此它可能有一个垂直滚动条
,但它可以水平增长(根据容器的内容需要),所以它从来没有水平滚动条
它必须在IE8,FF,Chrome(没有IE7或更早版本)中工作
解决方案首先是微不足道
但我无法摆脱IE8中的水平滚动条:
<!DOCTYPE HTML PUBLIC DTD HTML 4.01 Transitional // ENhttp://www.w3.org/TR/html4/loose.dtd\">
< html>
< body>
< div style =display:table; class =container-div-1>
< div style =display:table-cell; class =container-div-2>
< div style =overflow-y:scroll; height:19em; class =container-div-3>
< div style =width:30em; height:30em; background-color:red; class =example-content>< / div>
< / div>
< / div>
< / div>
< / body>
< / html>
在这个例子中,我们需要一个19em的高容器,可以根据内容的需要(在这种情况下,example-cotentdiv)
请不要修改example-contentdiv,因为它只是一个示例内容(任何内容都可能存在) / p>
这个问题是这个问题的泛化:
IE8水平滚动条问题
浮动可能会得到你想要的结果。请在这里查看我的示例:
http://jsbin.com/ivegi4/4/编辑
我带走了包含的div,因为我没有想到它们是必要的,但我不会看到一个问题,你绝对需要他们。
I ran into the following problem:
how to make a general container (HTML + CSS; no javascript)
that is contrained vertically (it has a fixed outer height), so it may have a vertical scrollbar
but that can grow horizontally (as needed by the content of the container), so it never has a horizontal scrollbar
it has to work in IE8, FF, Chrome (no IE7 or earlier)
the solution semms to be be trivial at first
but I can not get rid of the horizontal scrollbar in IE8:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div style="display: table;" class="container-div-1">
<div style="display: table-cell;" class="container-div-2">
<div style="overflow-y: scroll; height: 19em;" class="container-div-3">
<div style="width: 30em; height: 30em; background-color: red;" class="example-content"></div>
</div>
</div>
</div>
</body>
</html>
in this example, we need a 19em high container, that can grow horizontally, as needed by the content (in this case, the "example-cotent" div)
please don't suggest to modify the "example-content" div, as it is just a sample content (any content could be there)
this problem is the generalization of this issue: IE8 horizontal scrollbar problem
Floating will probably get the result you're looking for. Check out my example here:
http://jsbin.com/ivegi4/4/edit
I took away the containing divs, as I didn't think they were necessary, but I wouldn't see a problem adding them back in if you absolutely needed them.
这篇关于一般容器 - IE8水平滚动条问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!