<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
/*水平排列的盒子 间距是margin相加。垂直排列的盒子是取最大值*/
#div1{
height: 100px;
background-color: red;
margin-bottom: 20px;
}
#div2{
height: 100px;
background-color:brown;
margin-top: 30px;
}
</style>
<title>块级元素的上下边距</title>
</head>
<body>
<div id="div1">杰瑞教育1</div>
<div id="div2">杰瑞教育2</div>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
/*水平排列的盒子 间距是margin相加。垂直排列的盒子是取最大值*/
#div1{
height: 100px;
background-color: red;
margin-bottom: 20px;
}
#div2{
height: 100px;
background-color:brown;
margin-top: 30px;
}
</style>
<title>块级元素的上下边距</title>
</head>
<body>
<div id="div1">杰瑞教育1</div>
<div id="div2">杰瑞教育2</div>
</body>
</html>