
说明
1、浮动元素会从普通文档流中分离出来。
但浮动元素不仅会影响自己,还会影响周围元素的对齐。
2、无论是行内元素还是块级元素,如果设置了浮动,浮动元素就会产生块级框。
可以设置width和height,所以float通常用来制作横向配列的菜单,可以设置大小和横向排列。
3、浮动元素之间的外边距不会折叠。
浮动元素不会重叠。定位元素不同,可能会重叠。
实例
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8">
<title>浮动之特</title>
<style>
*{
padding:0;
margin:0;
}
.one,
.two{
width:200px;
height:200px;
background-color:pink;
}
.one{
float:left;
}
.two{
background-color:purple;
float:left;
}
.three{
float:left;
width:200px;
height:200px;
background-color:blue;
}
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
</body>
</html>
以上就是css浮动的特性,希望对大家有所帮助。更多css学习指路:css教程
原文来自:https://www.py.cn© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END



















































暂无评论内容