Created
June 29, 2023 23:14
-
-
Save chekle/c73a4d8de7b5e447001e7dfc643efaa0 to your computer and use it in GitHub Desktop.
Background Image Sizing using aspect ratio
This file contains hidden or 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
aspect-ratio: 16 / 9; | |
.image{ | |
aspect-ratio: 16 / 11; | |
background-repeat: no-repeat; | |
background-size:contain; | |
background-position:center; | |
} | |
This essentially makes a background image work proportionally across responsive/different screen sizes without having to set the height at each different breakpoint. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment