Created
June 14, 2021 12:05
-
-
Save d1i1m1o1n/f90d8b3d156783085c877250023b1da4 to your computer and use it in GitHub Desktop.
We can use CSS aspect-ratio today by using CSS @supports and CSS variables.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.card { | |
--aspect-ratio: 16/9; | |
padding-top: calc((1 / (var(--aspect-ratio))) * 100%); | |
} | |
@supports (aspect-ratio: 1) { | |
.card { | |
aspect-ratio: var(--aspect-ratio); | |
padding-top: initial; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment