gpt4 book ai didi

css - 一旦标题分成两行,就会在标题旁边 float

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

扩展 Making floated text break off onto the next line这基本上产生了这个:

enter image description here

一旦标题变长一点,如何保持段落的 float ?

enter image description here

期望的结果:

enter image description here

http://jsfiddle.net/frank_o/06ewqwun/9/

HTML:

<div class="test">
<h1>Test test test test test test</h1>
<div class="another">
<div class="subanother1">
<p>Another test another test</p>
</div>
</div>
</div>

CSS:

.test {
border: 1px solid black;
width: 300px;
}
h1 {
float: left;
border: 1px solid #ccc;
margin: 0;
padding: 0;
}
.another {
display: inline;
line-height: 1.5em;
}

最佳答案

您可以将 display: inline-block 添加到 .subanother1 类:

.test {
border: 1px solid black;
width: 300px;
}
h1 {
border: 1px solid #ccc;
margin: 0;
padding: 0;
display: inline;
}
.another {
display: inline;
line-height: 1.5em;
}

.subanother1{
display: inline-block;/*Add display inline block*/
line-height: 0em;/*Set line hight to 0em*/
}
<div class="test">
<h1>Test test test Test test test</h1>
<div class="another">
<div class="subanother1">
<p>Another test another test</p>
</div>
</div>
</div>

关于css - 一旦标题分成两行,就会在标题旁边 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26013861/

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