本文概述
- 怎么运行的
- CSS浮动属性
- CSS浮动属性值
- CSS Float属性示例
要了解其目的和来源, 让我们看一下它的印刷显示。在打印显示器中, 图像设置在页面中, 以便根据需要将文本环绕在页面中。
文章图片
它的Web布局也与打印布局类似。
文章图片
怎么运行的 【CSS浮动float】元素仅水平浮动。因此, 仅可以向左或向右浮动元素, 而不能向上或向下浮动元素。
- 浮动元素可以尽可能向左或向右移动。简单来说, 这意味着浮动元素可以显示在最左侧或最右侧。
- 浮动元素之后的元素将在其周围流动。
- 浮动元素之前的元素不会受到影响。
- 如果图像向右浮动, 则文本在其周围向左流动;如果图像向左浮动, 则文本在其周围向右流动。
属性 | 描述 | 价值观 |
---|---|---|
clear | clear属性用于避免在浮动元素之后流动的元素。 | 左, 右, 两者, 无, 继承 |
float | 它指定盒子是否应该浮动。 | 左, 右, 无, 继承 |
值 | 描述 |
---|---|
none | 它指定该元素未浮动, 并将显示在文本中刚出现的位置。这是默认值。 |
left | 用于将元素浮动到左侧。 |
right | 它用于使元素向右浮动。 |
initial | 它将属性设置为其初始值。 |
inherit | 它用于从其父元素继承此属性。 |
<
!DOCTYPE html>
<
html>
<
head>
<
style>
img {
float: right;
}
<
/style>
<
/head>
<
body>
<
p>
The following paragraph contains an image with style
<
b>
float:right<
/b>
. The result is that the image will float to the right in the paragraph.<
/p>
<
img src="http://www.srcmini.com/good-morning.jpg" alt="Good Morning Friends"/>
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.
<
/p>
<
/body>
<
/html>