Created
December 9, 2019 06:17
-
-
Save joshuapbritz/dd2a5d0768b1b6ecfd036147bf816241 to your computer and use it in GitHub Desktop.
@supports object fit
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
// This trick will make your image 30px wide and | |
// will automatically adjust the height of the | |
// image based on its aspect ratio. However, if | |
// the browser supports `object-fit`, the image | |
// will be made 30px by 30px and will size the | |
// image based on its aspect ratio | |
// (like background-size: cover) | |
img { | |
width: 30px; | |
height: auto; | |
} | |
@supports (object-fit: cover) { | |
img { | |
height: 30px; | |
object-fit: cover; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment