清除浮动的三种方法(推荐第三种)

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			.contend{
				border: 1px solid black;
			}
			.box1,.box2,.box3{
				width: 100px;
				height: 100px;	
			}
			.box1{
				background-color: rgb(0,255,0);
				float:left;
			}
			.box2{
				background-color: rgb(255,0,0);
				float:left;
			}
			.box3{
				background-color: rgb(0,0,255);
				float:left;
			}
			.clear{
				clear:both;
			}
			
			
			.conter{
				border: 1px solid black;
				overflow: hidden;
				zoom: 1;   /* 设置让其兼容IE */
			}
			.box11,.box22,.box33{
				width: 100px;
				height: 100px;	
			}
			.box11{
				background-color: rgb(0,255,0);
				float:left;
			}
			.box22{
				background-color: rgb(255,0,0);
				float:left;
			}
			.box33{
				background-color: rgb(0,0,255);
				float:left;
			}
			
			
			
			.fu{
				border: 1px solid black;
			}
			.clearfix:after{
				content: "";
				height: 0;
				display: block;
				visibility: hidden;
				clear: both;
			}
			.clearfix{
				zoom: 1;   /* 设置让其兼容IE */
			}
			.zi1,.zi2,.zi3{
				width: 100px;
				height: 100px;	
			}
			.zi1{
				background-color: rgb(0,255,0);
				float:left;
			}
			.zi2{
				background-color: rgb(255,0,0);
				float:left;
			}
			.zi3{
				background-color: rgb(0,0,255);
				float:left;
			}
		</style>
	</head>
	<body>
		<!-- 第一种 -->
		<div class="contend">
			<div class="box1">第一种清除浮动的方法</div>
			<div class="box2">第一种清除浮动的方法</div>
			<div class="box3">第一种清除浮动的方法</div>
			<div class="clear"></div>
		</div>
		<hr/>
		
		<!-- 第二种 -->
		<div class="conter">
			<div class="box11">第二种清除浮动的方法</div>
			<div class="box22">第二种清除浮动的方法</div>
			<div class="box33">第二种清除浮动的方法</div>
		</div>
		<hr/>
		
		<!-- 第三种 -->
		<div class="fu clearfix">
			<div class="zi1">第三种清除浮动的方法</div>
			<div class="zi2">第三种清除浮动的方法</div>
			<div class="zi3">第三种清除浮动的方法</div>
		</div>
		
		
	</body>
</html>

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值