CSS --- Margin of tips comprehension exercises

Implement the following small box

This article focuses on:
implementation of each strip box to the bottom margin of 1px
Here Insert Picture Description

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Margin的使用技巧理解练习</title>
	<style type="text/css">
		
		/* body是经常设置的值 */
		body{
			margin: 0;
		}
		.box{
			width: 202px;
			height: 156px;
			background-color: gold;
			
			margin:50px auto 0;
	
		}
		/* 层级选择器 */
		.box div{
			width: 200px;
			height: 30px;
			border: 1px solid green;
			background-color: gold;
			
			/* 这里是理解练习margin的一行代码 */
			margin-top:-1px ;
			
			/*  层叠样式表规则,下面的样式可以把上面的样式覆盖掉*/
			/* border-bottom: 0px; */
			
		}
		
	/* 	.box .last{
			border-bottom:1px solid green;
		} */
	</style>
</head>
<body>
	<div class="box">
		<div></div>
		<div></div>
		<div></div>
		<div></div>
		<div class="last"></div>
	</div>
</body>
</html>

Published 35 original articles · won praise 2 · Views 871

Guess you like

Origin blog.csdn.net/qq_43766304/article/details/104718247
Recommended