CSS-margin负值
今天发现的一个很有趣的问题<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
div.box1{
width: 300px;
/* height: 200px; */
background-color: red;
}
div.box2{
width: 100px;
height: 150px;
background-color: greenyellow;
}
div.box3{
width:60px;
height: 50px;
background-color: aqua;
margin-top: -1px; /* 尝试变换这个值 */
}
</style>
</head>
<body>
<div class="box1">
<div class="box2"></div>
<div class="box3"></div>
</div>
<p>这是一段文字</p>
</body>
</html>
页:
[1]