JSFiddle - React, Tailwind, and code Playground
HTML
<p>I have more content above this showreel link though</p>
<section id="head" class="working">
<div class="inner">
<ul id="work">
<li>
<span id="showhide">
Watch our showreel
</span>
</li>
</ul>
</div>
</section>
<div id="showreel">
<iframe src="http://www.youtube.com/embed/wHrmr0yeSrc?&color=white&theme=light&rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
<p>I need this content to be pushed down the page when the video is on show :)</p>
<p>I need this content to be pushed down the page when the video is on show :)</p>
<p>I need this content to be pushed down the page when the video is on show :)</p>
CSS
.inner {
max-width: 960px;
padding: 0 16px;
overflow: hidden;
margin: 0 auto;
}
section#head {
background: #424242;
min-height: 55px;
margin-bottom: 0;
}
#showreel {
position: relative;
height: 0;
overflow: hidden;
opacity: 0;
background: #424242;
}
iframe, video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#showhide {
cursor: pointer;
color: #fff;
}
#showhide.active:before { content: "âś–"; }
#showhide.active:after { content: "Hide"; }
JavaScript
//Hide the iframe first
$('iframe').hide();
$("#showhide").toggle(function(){
var newHeight = ($('#showreel').width()/16)*9;
$("#showhide").addClass("active");
$('#showreel').stop().animate({ height: newHeight, opacity: 1 }, 'slow', function(){$('iframe').fadeIn(200);});
}, function(){
$("#showhide").removeClass("active");
$('iframe').fadeOut(200, function(){$('#showreel').stop().animate({ height: 0, opacity: 0, padding: '0px' }, 'slow');} );
});
$(window).resize(function(){
// Resize video to fix aspect ratio when window resizes
// Only do this if video is currently visible
if ($('#showreel').height()!=0){
$('#showreel').height(($('#showreel').width()/16)*9);
}
});