【发布时间】:2018-10-21 06:25:42
【问题描述】:
我正在尝试将两个 div 并排放置,并牢记移动访问者。
问题:当 div 中使用大量文本时,它不是并排浮动,而是在下方。
这是一个例子:
.codeblock {
width:500px;
}
.left{
float: left;
}
<div class="codeblock">
<img src="https://placehold.it/307x322" class="left" style="width:125px">
<div class="left">
<h3>Some title</h3>
<p>Some text with a long explanation of how buildings don't make the Earth any heavier because all the materials were already on it.</p>
</div>
</div>
为什么会这样?有没有不使用固定值(不包括图片样式宽度)的解决方案?
【问题讨论】:
-
图片的宽度总是一样吗?
-
css 浮动是用于内容流,而不是用于“定位”的东西