Skip to content

Instantly share code, notes, and snippets.

@jeffersonRibeiro
Last active October 25, 2018 17:26
Show Gist options
  • Save jeffersonRibeiro/f96940fcbf14ad50b4a96d14f80bf1b0 to your computer and use it in GitHub Desktop.
Save jeffersonRibeiro/f96940fcbf14ad50b4a96d14f80bf1b0 to your computer and use it in GitHub Desktop.
Background aspect-ratio CSS
@media screen and (min-aspect-ratio: 16/9) {
.background {
width: 100%;
height: auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
@media screen and (max-aspect-ratio: 16/9) {
.background {
width: auto;
height: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment