Skip to content

Instantly share code, notes, and snippets.

@bpb54321
Created August 14, 2016 15:44
Show Gist options
  • Select an option

  • Save bpb54321/6551be7b8b884e1397cf69ed92596a22 to your computer and use it in GitHub Desktop.

Select an option

Save bpb54321/6551be7b8b884e1397cf69ed92596a22 to your computer and use it in GitHub Desktop.
Youtube video embed preserves aspect ratio across all screen sizes.
.youtube-video-wrap {
width: 100%;
max-width: 640px;
margin: 3rem auto;
}
.video-container {
position: relative;
padding-bottom: 56.25%; //16:9 aspect ratio, 9/16 = .5625. Padding is percentage of container width
height: 0;
overflow: hidden;
iframe {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment