Fix height content
Fix content height and read more will expand rest of the content
by rahilwazir
HTML
<div class="minimize">
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text.
Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text.
</p>
<iframe src="https://youtube.com">
</iframe>
</div>
<a href="#" class="more">Read More > </a>
CSS
p {
padding: 0 0 20px;
}
.minimize {
height: 50px;
overflow: hidden;
}
JavaScript
jQuery(function(){
var $box = $(".minimize");
var minimumHeight = $box.height();
$('a.more').click(function(event){
event.preventDefault();
$box = $(".minimize");
// get current height
currentHeight = $box.innerHeight();
// get height with auto applied
autoHeight = $box.css('height', 'auto').innerHeight();
// reset height and revert to original if current and auto are equal
$box.css('height', currentHeight).animate({
height: (currentHeight == autoHeight ? minimumHeight : autoHeight)
});
});
});