Skip to content

Instantly share code, notes, and snippets.

@dillonbailey
Created January 3, 2016 22:59
Show Gist options
  • Save dillonbailey/08dfe0eb5a49aa2f5d43 to your computer and use it in GitHub Desktop.
Save dillonbailey/08dfe0eb5a49aa2f5d43 to your computer and use it in GitHub Desktop.
Simple Responsive YouTube iFrames
// This variable only captures iframes with a youtube video, extend as required...
var video = $("iframe[src^='https://www.youtube.com']");
if (video.length) {
video.each(function() {
$(this).wrap("<div class='videoWrapper'></div>");
});
}
.videoWrapper {
position: relative;
padding-bottom: 56.25%;
padding-top: 25px;
height: 0;
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