margin 的设置关系

36 阅读1分钟
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
	<style>
		
		div.father	{
			background: #fffebb;
			text-align: center;
			font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", "serif";
			font-size: 12px;
			padding: 10px;
			border: 1px solid #000;
			height: 40px;
		}
		div.son {
			background: #a2d2ff;
			margin-top: 30px;
			margin-bottom: 0px;
			padding: 15px;
			border: 1px dashed #004993;
			
		}
		
		
	</style>

</head>
<body>

	<div class="father">
	<div class="son">子div</div>
	</div>

	


</body>
</html>

截屏2022-11-24 17.01.52.png

截屏2022-11-24 17.03.31.png