BFC外边距重叠

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>BFC外边距重叠</title>
		<style type="text/css">
			.box1{
				width: 100px;
				height: 100px;
				background-color: red;
				margin-bottom: 30px;
			}
			.box2{
				width: 100px;
				height: 100px;
				background-color: yellow;
				margin-top: 70px;
			}
			.parent{
				/* 触发bfc */
				/* display: inline-block; */
				overflow: hidden;
			}
		</style>
	</head>
	<body>
		<div class="parent">
			<div class="box1"></div>
		</div>
		<div class="box2"></div>
	</body>
</html>

 

posted @ 2022-10-25 14:22  JackieDYH  阅读(2)  评论(0编辑  收藏  举报  来源