webdesign/CSS
A fixed aspect ratio
yunsoo.note
2022. 1. 18. 05:03
5 More Must Know CSS Tricks That Almost Nobody Knows
06:09 - Aspect Ratio
aspect-ratio:16/9
https://caniuse.com/?search=aspect-ratio
https://matthiasott.com/notes/aspect-ratio-in-css
Maintain the aspect ratio of a div with CSS
element {
padding-top: %value;
}
aspect ratio | padding-top value
--------------|----------------------
1:1 | 100%
16:9 | 56.25%
4:3 | 75%
3:2 | 66.66%
8:5 | 62.5%
https://hyeonseok.com/blog/712
#movie-player-wrapper {
position: relative;
width: 100%;
height: 0;
overflow: hidden;
padding-bottom: 56.26%;
}
#movie-player-wrapper .wrap {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}