내 코드에 문제가 있습니까? 종횡비를 padding-bottom
으로 유지하는 대신 내부 div (두 개)가 외부 div를 채우는 이유는 무엇입니까? 당신이 당신의 one:before
플로트를 취소하지 않기 때문에종횡비 div 다른 종횡비 내 div 의도하지 않음
.one {
position: relative;
background: #990000;
background-size: contain;
}
.one:before {
content: "";
width: 1px;
margin-left: -1px;
float: left;
height: 0;
padding-bottom: 40%;
}
.one:after {
content: "";
display: table;
clear: both;
}
.two {
position: relative;
top: 0;
background: #009900;
}
.two:before {
content: "";
width: 1px;
margin-left: -1px;
float: left;
height: 0;
padding-bottom: 20%;
}
.two:after {
content: "";
display: table;
clear: both;
}
<div class="one">
<div class="two"></div>
</div>
https://jsfiddle.net/mhk99j8z/
스 니펫을 추가해 주셔서 감사합니다. – goyixeda