jquery - Expand parent div when height of position:absolute child div is increased -
i have parent div , 2 child div's.
<div id="parent"> <div class="child1 col-2"></div> <div class="child2 col-10"></div> </div>
the child1 absolutely positioned , contains collapsible items. when expand collapsible items in child1 height increases. how increase height of parent div and/or child2 div when height of child1 increases after page has loaded?
your first child (child1) position absolute, need calculate height of first div , assigned top value second div
html
<div id="parent"> <div class="child1 col-2">child1<br/>test1 <a class="collapse" href="#">collapse</a> <div class="insidediv"> test inside </div> </div> <div class="child2 col-10">child2</div> </div>
css
.child1 { position:absolute; } .child2 { position:relative; } .insidediv { display:none; }
jquery
var child1height = $(".child1").height(); $(".child2").css('top' , child1height); $(".child1 .collapse").click(function(){ $(".insidediv").slidedown(function(){ var countheight = $(".child1").height(); $(".child2").css('top' , countheight); }); })
Comments
Post a Comment