【发布时间】:2009-03-06 10:23:22
【问题描述】:
我正在使用page 中概述的等高 CSS 技巧。
直到今天,当我需要在其中一列中添加一个对话框时,一切都运行良好,该对话框的绝对位置可以使其脱离流程。问题是由于容器上有“溢出:隐藏”,当它溢出时对话被切断了。
除了将对话带到容器元素之外,有没有办法让它通过 CSS 显示?
这是一个小例子,展示了我提到的内容。
<style>
.container { overflow: hidden; margin-top: 30px }
.col {
float: left;
padding-bottom: 2000px;
margin-bottom: -2000px;
border-right: 1px solid black;
width: 100px;
background-color: grey;
}
.col.third { border-right: none }
#div-a { position: relative }
#div-b {
position: absolute;
background-color: red;
width: 35px;
height: 350px;
bottom: 0;
right: 0;
margin: 5px;
border: 2px solid black;
}
</style>
<div class="container">
<div class="col first">
<p style="height: 100px">One</p>
</div>
<div class="col second">
<p style="height: 300px">Two</p>
<div id="div-a">
<!-- this gets cut off by the "overflow: hidden" on div.container -->
<div id="div-b">
Foo
</div>
</div>
</div>
<div class="col third">
<p style="height: 200px">Three</p>
</div>
</div>
您会看到div#div-b 在div.container 元素中溢出时在顶部被截断。
【问题讨论】: