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.

example

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> 

fiddle https://jsfiddle.net/ishukshin/84k6tvp6/

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

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -