Skip to content

Instantly share code, notes, and snippets.

@donaldG
Last active August 29, 2015 14:24
Show Gist options
  • Save donaldG/f8b3547d930febdaabb6 to your computer and use it in GitHub Desktop.
Save donaldG/f8b3547d930febdaabb6 to your computer and use it in GitHub Desktop.
<script>
jQuery(document).ready(function($) {
$('iframe[src*="youtube.com"]').wrapAll('<div class="youtube-wrapper">');
$('.youtube-wrapper').wrapAll('<div class="video-player">');
});
</script>
<style>
.video-player {
clear: both;
width: 100%;
margin: 0 0 1em;
overflow: hidden;
}
.video-player .youtube-wrapper {
position: relative;
width: 100%;
height: 0;
margin: 0 auto 1em;
padding-bottom: 56.27%;
}
.video-player iframe{
position: absolute;
width: 100%;
height: 100%;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment