Skip to content

Instantly share code, notes, and snippets.

@joewanko
Last active April 7, 2017 08:58
Show Gist options
  • Save joewanko/b6f0ab1d66c37648b5f6 to your computer and use it in GitHub Desktop.
Save joewanko/b6f0ab1d66c37648b5f6 to your computer and use it in GitHub Desktop.
Trick to imitate `background-size: cover;` on img tags. Parent can be any element type.
.parent {
overflow: hidden;
position: relative;
.child {
bottom: -9999px;
left: -9999px;
margin: auto;
min-height: 100%;
min-width: 100%;
position: absolute;
right: -9999px;
top: -9999px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment