要求:
- 正方形;
- 寬度或高度有一個是100%;
- 自適應;
<!DOCTYPE html>
<html lang="en">
<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>Rect</title>
</head>
<body>
<style>
.rect {
/* width: 100%; */
max-width: 100vh;
/* height: 100%; */
max-height: 100vw;
background: yellowgreen;
margin: auto;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
</style>
<div class="rect"></div>
</body>
</html>