Created
December 16, 2022 18:36
-
-
Save nocodesupplyco/55d9f0ecd86a5ef1d8e2557677803160 to your computer and use it in GitHub Desktop.
CSS Aspect Ratio
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
/* Set aspect ratio on an element/class */ | |
.div { | |
aspect-ratio: 16 / 9; | |
} | |
/* Minimum aspect ratio */ | |
@media (min-aspect-ratio: 8/5) { | |
div { | |
background: #9af; /* blue */ | |
} | |
} | |
/* Maximum aspect ratio */ | |
@media (max-aspect-ratio: 3/2) { | |
div { | |
background: #9ff; /* cyan */ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment