모든 프론트 엔드 파트너에게 문제를 던지기 위해 16:9, 4:3과 같은 특정 비율을 유지하는 방법의 너비가있는 요소의 높이가 있습니다. 아래는 구현의 특성의 부모 요소 너비의 패딩 상속을 사용하는 솔루션입니다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
/* 부모 상자*/
.container {
width: 50%;
margin: 0 auto;
background-color: red;
}
/* 하위 상자*/
.inner {
width: 100%;
padding-bottom: 75%;
background-color: pink;
position: relative;
}
/* 컨테이너 서브박스는 높이가 없으므로 이를 담을 컨테이너가 필요합니다.*/
.item {
position: absolute;
width: 100%;
height: 100%;
}
</style>
<body>
<div class="container">
<div class="inner">
<div class="item"></div>
</div>
</div>
</body>
</html``





