html - How to make body as tall as huge absolutely positioned div in it? I need to have footer at the bottom -
a have page absolute positioned drop-down menu. when menu visible, it's higher, body, creates white space below footer, positioned @ bottom (bottom:0) of body.
the expected behavior footer goes down bottom of scrolled area , visible after scrolling bottom.
how force body increase height when dropdown shown or how make footer @ bottom? when tall div shown, there scrollbar in window, footer not @ bottom of scrolled contents. don't want use position: fixed since footer sticks bottom of window , visible.
<div style="position:relative"> <div style="position:absolute; height:1000px;right:30px;top:30px; border:1px solid red;"> long text </div> </div> <br> <div id="footer"> footer </div>
it not possible css absolutely positioned elements removed document flow, , dimensions cannot alter dimensions of parents. can done javascript calculating height of absolute elements , applying min-height parent.
var minheight = $(".child").height() + $("#footer").height(); $(".parent").css("min-height", minheight); #footer { height: 50px; background: darkblue; color: white; font-size: 16px; position: absolute; bottom: 0px; } body { position: relative; min-height: 100%; border: 2px solid grey; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="parent" style="position:relative"> <div class="child" style="position:absolute; height:1000px;right:30px;top:30px; border:1px solid red;"> tall text </div> </div> body tag has grey border <br> footer @ bottom of .. what? <br> absolutely positioned div taller body <br> <div id="footer"> footer </div> 
Comments
Post a Comment