gpt4 book ai didi

html - 正确排列 float 的 HTML 元素

转载 作者:太空宇宙 更新时间:2023-11-04 00:18:14 24 4
gpt4 key购买 nike

我正在使用 float 来安排布局。

<style>
div {
float: left;
}

.pro {
width : 100px;
color : blue;
}
</style>

<span>
<div class="pro">Long property name : </div>
<div>value</div>
</span>

当“长属性名称:”溢出到新行时,我希望“值”也转到新行。我应该在此 HTML 代码中做什么?谢谢。现在,“值(value)”仍然居于首位。

当前结果

Current result

我想要什么

enter image description here

谢谢

最佳答案

如果你使用 display: inline-block 而不是 float 会更好:

div {
display: inline-block;
*display: inline; /*For IE7*/
*zoom: 1;
}

检查这个:http://jsfiddle.net/thirtydot/wczcC/2/

关于html - 正确排列 float 的 HTML 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10381704/

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