Skip to content

Instantly share code, notes, and snippets.

@ruffle1986
Created July 9, 2014 13:29
Show Gist options
  • Save ruffle1986/2cc08cde41283dbba2ae to your computer and use it in GitHub Desktop.
Save ruffle1986/2cc08cde41283dbba2ae to your computer and use it in GitHub Desktop.
A CSS technique to keep 16:9 aspect ratio in the case of responsive video elements. ".video" refers to the video html element.
.player-wrapper {
position: relative;
width: 100%;
height: 0;
padding-bottom: percentage(9 / 16);
border: 1px solid black;
.video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: auto;
}
}
@ruffle1986
Copy link
Author

I hope you'll find it "+1".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment