📅  最后修改于: 2020-11-04 05:44:23             🧑  作者: Mango
CSS float属性是一个定位属性。它用于将一个元素向左或向右推,允许其他元素环绕它。通常用于图像和布局。
要了解其目的和来源,让我们看一下它的print显示。在print显示器中,图像设置在页面中,以便文本根据需要环绕在页面上。
它的Web布局也与print布局类似。
元素仅水平浮动。因此,仅可以向左或向右浮动元素,而不能向上或向下浮动元素。
Property | Description | Values |
---|---|---|
clear | The clear property is used to avoid elements after the floating elements which flow around it. | left, right, both, none, inherit |
float | It specifies whether the box should float or not. | left, right, none, inherit |
Value | Description |
---|---|
none | It specifies that the element is not floated, and will be displayed just where it occurs in the text. this is a default value. |
left | It is used to float the element to the left. |
right | It is used to float the element to the right. |
initial | It sets the property to its initial value. |
inherit | It is used to inherit this property from its parent element. |
让我们看一个简单的示例,以了解CSS float属性。
The following paragraph contains an image with style
float:right. The result is that the image will float to the right in the paragraph.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.