CSS 学习之消除浮动_01


<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>消除浮动一</title>
		<style>
			.one{
				
				width: 500px;
				background-color: pink;
				border:1px solid red;
			}
			.damao {
				float:left;
				width: 200px;
				height: 200px;
				background-color: purple;
			}
			.ermao{
				float:left;
				width: 250px;
				height: 250px;
				background-color: skyblue;
			}
			.two{
				
				width: 700px;
				height: 150px;
				background-color: #000;
			}
			.clear{
				clear:both;
			}
		</style>
	</head>
	<body>
		<div class="one">
			<div class="damao"></div>
			<div class="ermao"></div>
			<div class="clear"></div>
		</div>
		<div class="two"></div>
	</body>
</html>
额外标签法(隔墙法)
适用对象:盒子一中镶嵌两个浮动的盒子,并且不给盒子一高度。
这是盒子二就会到两个浮动盒子的下面。
解决办法:给盒子一中最后一个浮动盒子添加一个浮动的div。并在格式里定义为clear:both.
即可消除浮动,体现出盒字一的位置。

猜你喜欢

转载自blog.csdn.net/weixin_44079801/article/details/106967586
今日推荐