Skip to content

Instantly share code, notes, and snippets.

@joshuapbritz
Created December 9, 2019 06:17
Show Gist options
  • Save joshuapbritz/dd2a5d0768b1b6ecfd036147bf816241 to your computer and use it in GitHub Desktop.
Save joshuapbritz/dd2a5d0768b1b6ecfd036147bf816241 to your computer and use it in GitHub Desktop.
@supports object fit
// 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