Note that there are some explanatory texts on larger screens.

plurals
  1. POAlign variable height child div to bottom of variable height parent div, while another child pushes it down
    primarykey
    data
    text
    <p>The title is probably more complex than the idea itself. Below is an image showing what I need. There are simple rules:</p> <ul> <li>A is a div with min-height: 800px; if B+C>A (in height), then A should expand to fit both B and C. (Standard behavior).</li> <li>B is a div that is variable height and needs to always be aligned to top of A, regardless of the height of C.</li> <li>C is a div that has variable height and needs always be aligned to the bottom of A, regardless of the height of B.</li> <li>The heights of B &amp; C are determined by their contents (text mostly).</li> </ul> <p><img src="https://i.stack.imgur.com/SplWF.png" alt="align variable height div to bottom of parent"></p> <ul> <li>The leftmost image shows what it should look like when the the heights of B + C &lt; height of A. (Min-height 800px applies)</li> <li>The center image shows what should happen if B + C > A (B has grown in height, C has stayed the same, and thus, A has also grown in height).</li> <li>The rightmost image shows what should happen if B + C > A (both B and C have grown in height, and thus, A has also grown in height).</li> </ul> <p>Is this even possible with pure HTML/CSS and no Javascript? The execution environment does not have Javascript capability (or if it has, it's a very limited one), so I probably cannot rely on JS-based solutions.</p> <p>My own first attempt was to make A <code>position: relative;</code> and make C <code>position:absolute; bottom: 0;</code> but then when B grows, it will overlap with C, because C is no longer in the page flow.</p> <p>Then I thought about giving B a <code>min-height</code> that would push C to the bottom, but that doesn't work either because C does not have a fixed height, which means I cannot specify a fixed <code>min-height</code> for B.</p> <p>I also tried working with making A <code>display: table-cell; vertical-align: bottom;</code>, but that would then push both B &amp; C to the bottom. Perhaps if I could make B fill the rest of the available space, I could make this approach work?</p> <p>I created this jsfiddle <a href="http://jsfiddle.net/376rp/" rel="nofollow noreferrer">http://jsfiddle.net/376rp/</a> so that anyone who has any ideas has a jump-start. Please note: there are two "B"-blocks there (with a yellow background). The correct solution should probably work with any number of "B"-blocks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload