Note that there are some explanatory texts on larger screens.

plurals
  1. POMiddle div with 100% in CSS?
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/5657964/css-percentage-height">CSS - percentage height</a> </p> </blockquote> <p>I can't get the middle div of 3 divs to fit 100% of available space.</p> <pre><code>&lt;body&gt; &lt;div id="container"&gt; &lt;div id="header"&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;/div&gt; &lt;div id="footer"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>My CSS is:</p> <pre><code>html, body { margin: 0; padding: 0; border:1px; vertical-align:top; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:14px; color:#333; height: 100%; } #container { height: 100%; width: 100%; } #header { height: 100px; width: 100%; background: #069; } #content { height: 100%; width: 100%; background: #F60; } #footer { height: 75px; width: 100%; background: #060; } </code></pre> <p>Center div is in effect being 100%, but its not fitting available space.</p> <p><strong>It is doing something like this: If the screen is 500px</strong></p> <pre><code>30px 100% (500px) 30px </code></pre> <p><strong>What I need is:</strong></p> <pre><code>30px 100% (460px) 30px </code></pre> <p>Is this possible withouth using javascript?</p> <p>Thanks a lot</p> <p><strong>EDIT:<br> Sorry I meant Height I have 3 elements, header, middle and footer. Header and footer have fixed height, but I want middle to fit all available space</strong></p> <p>Found another solution based on other stackoverflow question:</p> <pre><code>* { margin: 0; padding: 0 } html, body { margin: 0; padding: 0; vertical-align:top; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:14px; color:#333; height: 100%; border: 0; } #header { height: 100px; background:#C60; } #container { min-height: 100%; height: auto !important; /*Cause footer to stick to bottom in IE 6*/ height: 100%; margin: 0 auto -100px; /*Allow for footer height*/ vertical-align:bottom; background:#096; } #footer { height: 100px; /*Push must be same height as Footer */ background:#C60; } </code></pre> <p>HTML</p> <pre><code>&lt;body&gt; &lt;div id="container"&gt; &lt;div id="header"&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="footer"&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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