html+css笔记12

folat:left/right/none
特点:
1.脱标:脱离标准流
2.一行内显示并且元素顶部对齐
3.具有行内块元素的特点

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>取消浮动</title>
	</head>
	<style>
		.box{
			background-color: pink;
			/* overflow:hidden; */
		}
		.box div{
			width: 12.5rem;
			height: 3.125rem;
			float: left;
			border: white 1px solid;
			background-color: darkred;
			color: white;
			font-size: 1.5rem;
			text-align: center;
			line-height: 3.125rem;
			font-family: 华文行楷;
		}
		.content{
			width: 125rem;
			height: 12.5rem;
			background-color: green;
			border: 1px solid black;
		}
		/* 第二种清除浮动的方法: */
		.clearfix:after{
			content: "";  /* 内容:"" */
			display: block;  /* 转换块元素 */
			height: 0;
			clear: both;  /* 清除左右两端的浮动 */
			visibility: hidden;  /* 显示状态:隐藏 */
		}
		/* 兼容IE6,7版本浏览器 */
		.clearfix{
			*zoom: 1;
		}
		/* 第三种清除浮动的方法: */
		.clearfix:after,.clearfix:before{
			content: "";
			display: table;
		}
		.clearfix:after{
			clear: both;
		}
		.clearfix{
			*zoom: 1;
		}
		/* 取消浮动 */
		/* 1.给父元素添加overflow:hidden */
		/* 2.添加伪元素 */
	</style>
	<body>
		<div class="box clearfix">
			<div>我的音乐</div>
			<div>流行音乐</div>
			<div>网络歌曲</div>
			<div>欧美音乐</div>
			<div>华语音乐</div>
			<div>抖音音乐</div>
		</div>
		<div class="content"></div>
	</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值