1. 代码实现
<!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>画一个大小为父元素宽度一半的正方形</title>
</head>
<style>
.far-div {
width: 200px;
height: 100px;
background-color: skyblue;
}
.son-div {
width: 50%;
padding-bottom: 50%;
background-color: orangered;
}
</style>
<body>
<div class="far-div">
<div class="son-div"></div>
</div>
</body>
</html>