2021-03-17

第二种清除浮动的方法:
.clearfix:after{
content:""; /内容:content/
display: block; /转换成块元素/
height: 0px;
clear: both; /清除左右两端的浮动/
visibility:hidden; /显示状态:隐藏/
}
/兼容IE6,7/
.clearfix{
*zoom:1;
}
第三种清除浮动的方法:
.clearfix:after,.clearfix:before{
content:"";
display:table;
}
.claerfix:after{
clear: both;
}
.clearfix{
*zoom: 1;
}

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>取消浮动</title>
		<style>
			.box{
				background-color: pink;
				/*overflow: hidden;*/
			}
			.box div{
				float: left;
				width: 200px;
				height: 50px;
				border: solid 1px white;
				background-color: darkred;
				font-size: 24px;
				color: #FFF;
				text-align: center;
				line-height: 50px;
			}
			.centen{
				width: 2000px;
				height: 200px;
				background-color:green;
				border: solid 1px balck;
			}
			/*第二种清除浮动的方法:*/
			.clearfix:after{
				content:"";  /*内容:content*/
				display: block;  /*转换成块元素*/
				height: 0px;
				clear: both;  /*清除左右两端的浮动*/
				visibility:hidden;  /*显示状态:隐藏*/
			}
			/*兼容IE6,7*/
			.clearfix{
				*zoom:1;
			}
			第三种清除浮动的方法:
			.clearfix:after,.clearfix:before{
				content:"";
				display:table;
			}
			.claerfix:after{
				clear: both;
			}
			.clearfix{
				*zoom: 1;
			}
			/*取消浮动*/
			/*1.给父元素添加overflow: hidden;*/
			/*2.添加伪元素*/
		</style>
	</head>
	<body>
		<div class="box clearfix">
			<div>我的音乐</div>
			<div>流行歌曲</div>
			<div>网络歌曲</div>
			<div>欧美音乐</div>
			<div>华语经典</div>
		</div>
		<div class="centen">内容区</div>
	</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值