css中的浮动属性值有哪些

2021-02-26,

css中的浮动属性值有:left、right、none、inherit。float浮动属性可以使元素向左或向右移动,其周围的元素也会重新排列,往往用于图像布局中。

/2021/02/11ced841.jpg

本文操作环境:windows10系统、css 3、thinkpad t480电脑。

浮动属性介绍:

CSS 的 Float(浮动),会使元素向左或向右移动,其周围的元素也会重新排列。Float(浮动),往往是用于图像,但它在布局时一样非常有用。

浮动属性:

clear 指定不允许元素周围有浮动元素(清除浮动)。

  • left

  • right

  • both

  • none

  • inherit

float 指定一个盒子(元素)是否可以浮动。

  • left

  • right

  • none

  • inherit

举例:

<style>
.thumbnail 
{
	float:left;
	width:110px;
	height:90px;
	margin:5px;
}
</style>
</head>

<body>
<h3>图片库</h3>
<p>试着调整窗口,看看当图片没有足够的空间会发生什么。</p>
<img class="thumbnail" src="/images/klematis_small.jpg" width="107" height="90">
<img class="thumbnail" src="/images/klematis2_small.jpg" width="107" height="80">
<img class="thumbnail" src="/images/klematis3_small.jpg" width="116" height="90">
<img class="thumbnail" src="/images/klematis4_small.jpg" width="120" height="90">
<img class="thumbnail" src="/images/klematis_small.jpg" width="107" height="90">
<img class="thumbnail" src="/images/klematis2_small.jpg" width="107" height="80">
<img class="thumbnail" src="/images/klematis3_small.jpg" width="116" height="90">
<img class="thumbnail" src="/images/klematis4_small.jpg" width="120" height="90">
</body>
</html>

运行结果:

/2021/02/e818cec7.png" /2021/02/e818cec7.png" alt="fd3205e41fa6db78add7d887d8c2c5c.png

/2021/02/b9a0856f-1.png" /2021/02/b9a0856f-1.png" alt="f2aa4ecf6d2742c9db34ab24c94dbcc.png

相关推荐:CSS教程

以上就是css中的浮动属性值有哪些的详细内容,更多请关注北冥有鱼其它相关文章!

本文转载自【PHP中文网】,希望能给您带来帮助,苟日新、日日新、又日新,生命不息,学习不止。

《css中的浮动属性值有哪些.doc》

下载本文的Word格式文档,以方便收藏与打印。