jcadima
11/11/2015 - 7:15 PM

Responsive iframe Video

Responsive iframe Video

REF: http://www.smashingmagazine.com/2014/02/making-embedded-content-work-in-responsive-design/

REF2: https://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php


<div class="video-container">
    <iframe src="http://www.youtube.com/embed/4aQwT3n2c1Q" height="315" width="560" allowfullscreen="" frameborder="0">
    </iframe>
</div>


############## METHOD 1 ##################
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 35px;
    height: 0;
    overflow: hidden;
}

.video-container iframe {
    position: absolute;
    top:0;
    left: 0;
    width: 100%;
    height: 100%;
}


############# METHOD 2 ###############
.videoWrapper {
	position: relative;
	padding-bottom: 56.25%; /* 16:9 */
	padding-top: 25px;
	height: 0;
}
.videoWrapper object,
.videoWrapper embed {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}