我正在尝试让一些嵌套的 div 标签根据其中的内容自动增加高度。示例代码是 given here .比如中间的内容多了一些,但是高度好像没有增加。让它自动增长的技巧是什么?我从 parent 内部取出了所有 float 元素,认为它可能是 CSS clear rule .但这也无济于事。感谢任何帮助。
<div id="editmain">
<div class="ticker">
some content here
</div>
<div class="ticker">
some longer content content here
</div>
<div class="ticker">
some content here
</div>
</div>
#editmain
{
position:relative;
min-height:480px;
background-color:#84d;
overflow:hidden;
padding: 20px 0px 30px 0px;
}
.ticker
{
position:relative;
border-bottom: solid 2px #ddd;
margin:10px;
background-color:white;
overflow:hidden;
height:auto;
min-height:100px;
}
最佳答案
In the absolute positioning model, a box is removed from the normal flow entirely (it has no impact on later siblings) and assigned a position with respect to a containing block.
移除绝对定位并找到另一种使用宽度和边距来格式化标签和输入的方法。 Fiddle
.tickertxtlabel
{
display:inline-block;
margin: 10px 10px 10px 10px;
width:90px;
}
关于css - 嵌套的 DIV 标签和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15029077/