<!DOCTYPE html>
<html>
<head>
<title>近视视图</title>
<link rel="stylesheet" type="text/css" href="jinshishitu.css">
</head>
<body>
<div class="box1">
<div class="box2">
<div class="box3">
<div class="box4">
</div>
</div>
</div>
</div>
</body>
</html>
.box4{
width: 0px;
height: 0px;
border: 20px solid yellow; //记住width和height为0;
也可以写成这样:
width:0px;
height:0px;
padding:20px;
background-color:yellow;
}
.box3{
width: 40px;
height: 40px;
padding: 20px;
background-color: blue;
}
.box2{
width: 80px;
height: 80px;
padding: 20px;
background-color: red;
}
.box1{
width: 120px;
height: 120px;
padding: 20px;
background-color: orange;
}
效果如下:
![](https://img-blog.csdnimg.cn/20191002140749154.png)