Skip to content

Instantly share code, notes, and snippets.

@ddneat
Last active May 18, 2017 11:01
Show Gist options
  • Save ddneat/9515698 to your computer and use it in GitHub Desktop.
Save ddneat/9515698 to your computer and use it in GitHub Desktop.
responsive 16:9 ratio with plain css
// 16:9 aspect ratio (9/16 = 56.25%), use 75% for 4:3
// you can also add padding-top to add some extra space
.image-wrapper {
background-color: #000;
width: 100%;
padding-bottom: 56.25%;
position: relative;
}
.image-wrapper img {
position: absolute;
width: 100%;
top: 0;
left: 0;
height: 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment