Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CSS: Responsive video hack
/***********************************************************************************************/
/*
http://www.developerdrive.com/2012/07/adding-responsive-videos-to-your-design/
RESPONSIVE VIDEO HACK
*/
/***********************************************************************************************/
/*Restrict the width of videos*/
.video-wrapper {
width: 600px;
max-width: 100%;
}
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-container iframe,
.video-container object,
.video-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/*HTML*/
<div class="video-wrapper">
<div class="video-container">
<iframe width="640" height="360" src="//www.youtube.com/embed/3R2cnxz27LI" frameborder="0" allowfullscreen></iframe>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.