gpt4 book ai didi

css - 除非我给它最小高度,否则 Div 没有高度

转载 作者:搜寻专家 更新时间:2023-10-31 22:04:24 24 4
gpt4 key购买 nike

我认为这是因为我将所有三个 div“列” float 到左侧,在主体 div 的内部。

如何让主体 div 扩展到适合内容 div 所需的大小?

这是最小高度: alt text

这里去掉了最小高度: alt text

这是我的相关代码。

#body
{
border:1px solid blue;
width:950px;
margin-left:auto;
margin-right:auto;
margin-top:15px;
}

#leftcolumn
{
min-height:500px;
float:left;
width:190px;
}

#contactarea
{
font-family:Arial;
}

#contactarea p.heading
{
Color:#000;
font-size:large;
position:relative;
left:14px;
}

#contactarea p.tag
{
color:#000;
font-size:medium;
position:relative;
left:10px;
}

#leftnavigation ul
{
margin:0;
padding: 0;
list-style: none;
}
#leftnavigation ul li {
border-top: 1px solid #333;
border-bottom: 1px solid #111;
}
#leftnavigation ul li:first-child {border-top: none;}
#leftnavigation ul li:last-child {border-bottom: none;}
#leftnavigation ul li a
{
padding: 10px;
display: block;
color: #fff;
background-color:#222222;
text-decoration: none;
}
#leftnavigation ul li a:hover {background: #111;}

#contentarea
{
border:1px solid blue;
min-height:500px;
float:left;
width:594px;
margin-left:5px;
margin-right:5px;
}

#advertisingarea
{
width:150px;
float:left;
min-height:500px;
background-image:url('images/advertisingAreaBackground.png');
background-repeat:repeat-y;
}

.advert
{
height:190px;
overflow:hidden;
}

.advert img
{
padding:0;
margin:0;
position:relative;
left:25px;
top:5px;
}

.advert p
{
font-size:x-small;
font-family:Arial;
margin-left:8px;
margin-right:8px;
margin-top:5px;
}

<div id="body">
<div id="leftcolumn">
<div id="leftnavigation">
<ul>
<li><a href="#">Automoviles</a></li>
<li><a href="#">Clases y Talleres</a></li>
<li><a href="#">Electronicos</a></li>
<li><a href="#">Inmobiliaria</a></li>
<li><a href="#">Libros</a></li>
<li><a href="#">Musica, Peliculas y Juegos</a></li>
<li><a href="#">Ninos</a></li>
<li><a href="#">Otros</a></li>
<li><a href="#">Ropa</a></li>
</ul>
</div>
<div id="contactarea">
<p class="heading">Anuncios Premium</p>
<p class="tag">Destaque sus anuncios con una cuenta premium!</p>
</div>
</div>
<div id="contentarea">sdfg<h1>asdasd</h1></div>
<div id="advertisingarea">
<div class="advert">
<a href="#"><img src="../../Content/images/advertImage.png" alt="Advert" /></a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nibh nisi, volutpat a vehicula eget</p>
</div>

<div class="advert">
<a href="#"><img src="../../Content/images/advertImage.png" alt="Advert" /></a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nibh nisi, volutpat a vehicula eget</p>
</div>

<div class="advert">
<a href="#"><img src="../../Content/images/advertImage.png" alt="Advert" /></a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nibh nisi, volutpat a vehicula eget</p>
</div>
</div>
</div>

最佳答案

最简单的方法就是set the oveflow of the container :

#body
{
...
overflow: auto;
}

关于css - 除非我给它最小高度,否则 Div 没有高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3963002/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com