gpt4 book ai didi

css - 父div的高度不调整

转载 作者:行者123 更新时间:2023-11-28 12:58:04 24 4
gpt4 key购买 nike

我正在尝试创建一个流畅的布局,但容器的高度有一个小问题。外层<div> (黄色,ip_A-1)没有调整到它 child 的高度。

查看 fiddle在这里。

我试过在里面放一个垫片,但没用。同时制作 ip_BA_1 和 ip_BB_1 position:relative什么都不做。

HTML:

<div class="ip_A_1">
<div class="ip_BA_1">Hello I am a label that has to wrap</div>
<div class="ip_BB_1">
<div class="ip_BBA_1">Hello I am a text that has to wrap.
Hello I am a text that has to wrap.
Hello I am a text that has to wrap.</div>
</div>
<div class="spacer_0"></div>
</div>

<div class="spacer_0"></div>

<div class="ip_A_1">
<div class="ip_BA_1">Hello I am a label that has to wrap</div>
<div class="ip_BB_1">
<div class="ip_BBA_1">Hello I am a text that has to wrap.
Hello I am a text that has to wrap.
Hello I am a text that has to wrap.</div>
</div>
<div class="spacer_0"></div>
</div>

CSS:

.spacer_0 {
clear:both;
width:100%;
height:0px;
}
.ip_A_1 {
position: relative;
width: 100%;
height: auto;
min-height: 28px;
text-align: left;
font-family:'Calibri', 'Gill Sans', 'Helvetica', sans-serif;
font-size:1em;
background: yellow;
}
.ip_BA_1 {
float: left;
width: auto;
padding: 4px 10px 20px 45px;
font-family:'Calibri', 'Gill Sans', 'Helvetica', sans-serif;
font-size: 0.88889em;
line-height: 0.88889em;
font-weight: bold;
background: blue;
color: white;
}
.ip_BB_1 {
clear: both;
float: left;
margin-top: -15px;
width: 100%;
}
.ip_BBA_1 {
position: absolute;
left: 30px;
right: 0px;
padding-left: 6px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: #ccc;
border: 1px solid #666;
}

最佳答案

问题是您在 child 身上使用 float 和 position:absolute; 这些规则阻止 child 扩大 parent 的高度。

关于css - 父div的高度不调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21985795/

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