I have several divs on one page that each have a "see more details" link. When clicked, the div expands and should fill the height of the parent div with no issues. however, each div overflows onto the next parent div until i scroll, then it adjusts. how do i make the div grow without spilling over?
what's happening now
what i want to happen
$(function() {
var minHeight = null;
var expCb = function($el) {
$el.addClass('expanded');
$el.find('.expand-details').text('Details -');
};
var collapseCb = function($el) {
$el.removeClass('expanded');
$el.find('.expand-details').text('Details +');
};
$('.details-content a.expand-details').click(function() {
var currentCb = $(this).parent().hasClass('expanded') ? collapseCb : expCb;
currentCb($(this).parent());
updateCardDetailsLockups();
return false;
});
});
.details-content {
max-height: 18px;
overflow-y: hidden;
}
.details-content.expanded {
max-height: 2000px;
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parent1">
<div class="child col1">
<div class="details-content">
<a href="#" class="details-header expand-details">details +</a> ...
</div>
</div>
<div class="child col2">
...
</div>
</div>
<div class="parent2">
<div class="child col1">
<div class="details-content">
<a href="#" class="details-header expand-details">details +</a> ...
</div>
</div>
<div class="child col2">
...
</div>
</div>