gpt4 book ai didi

使用 float 时 Css 问题 div 高度

转载 作者:技术小花猫 更新时间:2023-10-29 11:31:58 24 4
gpt4 key购买 nike

我有一个像这样的 div 区域:

<div class="con">
<div class="container"></div>
<div class="sidebar"></div>
</div>

和 CSS:

.con{
width:100%;
}
.con .container{
width:70%;
min-height:500px;
float:left;
background:#f00;

}
.con .sidebar{
width:30%;
min-height:500px;
float:right;
background:#ccc;

}

containersidebar 类高度是动态的。当其中一个类高度增加时,类 con 也必须增加。但我的问题是类 con 高度始终为 0,我似乎无法为 con 类提供静态高度。

最佳答案

overflow: auto;添加到.con:

.con {
width: 100%;
overflow: auto;
}

关于使用 float 时 Css 问题 div 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14743709/

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