我有以下DIV
<div id="products">
</div>
#products
{
height: 102px; width: 84%;
padding:5px; margin-bottom:8px;
border: 1px solid #EFEFEF;
}
Run Code Online (Sandbox Code Playgroud)
现在在DIV中,我动态生成4个链接.但有时可能会有多于或少于4个链接.如何更改CSS以根据其内容动态调整DIV的大小?
Chi*_*e G 40
设置 height: auto;如果你想拥有最小高度为x,那么你可以写
height:auto;
min-height:30px;
height:auto !important; /* for IE as it does not support min-height */
height:30px; /* for IE as it does not support min-height */
Run Code Online (Sandbox Code Playgroud)