【发布时间】:2015-06-03 02:46:17
【问题描述】:
我有以下 HTML 标记 -
<div class="bar">
<p> Example Text </p>
</div>
<div class="dynamic-height">
<div class="box">
<p> Example Text 1</p>
</div>
</div>
<div class="footer">
This is footer
</div>
和下面的 CSS -
.bar{
height:20px;
width:100%;
}
.box
{
float:left;
width:50px
height:50px;
border:1px solid black;
}
.dynamic-height
{
min-height:50px;
width:100%;
}
. body
{
height:200px;
}
.footer
{
height:20px;
position:relative;
bottom:0;
}
以下是这些 div 的预期规则 -
-
“动态高度”类的 div 会有更多
元素 使用javascript动态添加到它。所以它的高度是 动态
具有“footer”类的 div 必须始终位于底部,并且动态高度和 footer div 之间的距离应始终为 10px; (边距:10px)
解决问题 -
当我使用javascript添加一个动态“p”元素到具有类“dynamic-height”的div时,这个div的高度会增加,如果我继续添加“p”元素,高度会增加,然后它与页脚 div 重叠。
我只想在页脚 div 和动态高度 div 之间始终保持 10 像素的距离
【问题讨论】:
标签: javascript jquery html css