분류
css
가변 폭의 요소가 주어지면, 높이가 반응하는 방식
본문
HTML :
<div class="constant-width-to-height-ratio"></div>
CSS :
.constant-width-to-height-ratio {
background: #333;
width: 50%;
}
.constant-width-to-height-ratio::before {
content: '';
padding-top: 100%;
float: left;
}
.constant-width-to-height-ratio::after {
content: '';
display: block;
clear: both;
}
- 이전글CSS로 카운터 구현 18.08.31
- 다음글float된 요소를 자동으로 clear하기 18.08.31