简体   繁体   English

为什么文字包裹漂浮的图像?

[英]why text wraps floated image?

As you know when we float an HTML element, we remove it from normal flow and other elements act as if there was no element at all, they just don't see it. 如你所知,当我们浮动一个HTML元素时,我们将它从正常流中移除,而其他元素就好像根本没有元素一样,它们只是看不到它。 But why text starts to wrap around floated image, isn't it suppose to go underneath the image? 但是为什么文本开始环绕浮动图像,是不是它想在图像下面?

You seem to confuse absolute positioning with a flow layout . 您似乎将绝对定位流布局混淆。 Floated elements are moved to the left/right, and text does respect them by wrapping around. 浮动元素移到左/右,以及文通过围绕尊重他们。

This article goes a bit crazy, but does a great job going through everything about the float property. 这篇文章有点疯狂,但是关于float属性的一切都做得很好。

"The purpose of the CSS float property is, generally speaking, to push a block-level element to the left or right, taking it out of the flow in relation to other block elements. This allows naturally-flowing content to wrap around the floated element. This concept is similar to what you see every day in print literature, where photos and other graphic elements are aligned to one side while other content (usually text) flows naturally around the left- or right-aligned element." “一般来说,CSS浮动属性的目的是向左或向右推动块级元素,将其从与其他块元素相关的流中取出。这允许自然流动的内容环绕浮动这个概念类似于你每天在印刷文献中看到的概念,其中照片和其他图形元素在一侧对齐,而其他内容(通常是文本)自然地围绕左对齐元素或右对齐元素流动。

http://coding.smashingmagazine.com/2009/10/19/the-mystery-of-css-float-property/ http://coding.smashingmagazine.com/2009/10/19/the-mystery-of-css-float-property/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM