【发布时间】:2014-06-27 08:51:43
【问题描述】:
当元素的顶部对齐时,让文本环绕 div 没有问题,但我不知道如何让文本环绕 div 上方和下方。
例如,我希望文本是 #container 的全宽 40px,然后向右环绕它,然后再次全宽。
查看http://jsfiddle.net/cope360/wZw7T/1/。我将上边距添加到#inset 的位置是我希望文本换行的位置。这可能吗?
CSS:
#inset {
width: 100px;
height: 100px;
background: gray;
float: left;
margin-top: 40px;
}
HTML:
<div id="container">
<div id="inset">Inset</div>
This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around. This text should wrap all around.
</div>
【问题讨论】:
-
容器是否需要作为 html 中的第一个子项?或者你也可以把它放在文本中的某个地方吗?
-
@Marnix,它可以放在任何地方。 HTML 可以以任何方式构造。我只是试着做一个最简单的例子来说明问题。