Skip to content

Instantly share code, notes, and snippets.

@manbearwolf
Created July 15, 2017 01:57
Show Gist options
  • Save manbearwolf/71b95a7c29d90779f8fff62957b830ba to your computer and use it in GitHub Desktop.
Save manbearwolf/71b95a7c29d90779f8fff62957b830ba to your computer and use it in GitHub Desktop.
Center the Hell! Out of YouTube Embedded Videos (Put it in Main.css)
/*
Centers the hell
out of Embeded Videos
*/
.video-container {
position:relative;
padding-bottom:56.25%;
padding-top:30px;
height:0;
overflow:hidden;
width:100%;
}
.video-container iframe, .video-container object, .video-container embed {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
margin: auto;
width:100%;
height:100%;
}
Example in HTML:
<div class="video-container">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/bUqy0jlqmAU/0.jpg" frameborder="0" src="https://www.youtube.com/embed/bUqy0jlqmAU?feature=player_embedded"></iframe>
</div>
@manbearwolf
Copy link
Author

Sometimes video...
.video-container {
width:100%;
}

line isn't needed.

@manbearwolf
Copy link
Author

manbearwolf commented Aug 28, 2017

padding-top:0px;
on blog theme.

theme already centers... (as well)! Bottom is maybe all you need.

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