Created
January 3, 2016 22:59
-
-
Save dillonbailey/08dfe0eb5a49aa2f5d43 to your computer and use it in GitHub Desktop.
Simple Responsive YouTube iFrames
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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>"); | |
}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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