Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's your solution.</p> <p>After my initial post, I figured why not slap together one of those handy JS Fiddles, so here you go: <strong><a href="http://jsfiddle.net/8uHF6/" rel="nofollow noreferrer">http://jsfiddle.net/8uHF6/</a></strong></p> <p>Forget all that frustrating business of trying to use wrappers and set other elements to 100% height to squeeze the extra vertical space out of the layout, and so on. You just end up in a situation where you poke over here, and something squirts out over there, so you poke over there, and something squirts out somewhere else. Ugh.</p> <p>Use absolute positioning for your main layout elements. Basically, you nail the elements down exactly where you want them by specifying their top and/or bottom values, including your main content element, which will automatically scale to fit the available space as your window changes size vertically.</p> <p>Tell your main content element to use automatic overflow, so the content will appear to slide under the footer, out of sight. A scrollbar will appear automatically if it's needed. Float the main content elements if you want a floated layout inside of them (otherwise, don't bother). You can use a fluid or elastic grid layout inside of something like this, and so on.</p> <p>Also, note that there is no overall "site-wrapper" or "page" div, which is kind of nice since the real goal of the semantic web is that your HTML contains content, and only content (HTML is <em>data</em>, not <em>layout</em>). Adding things like wrappers to your HTML to control layout is unfortunate. If possible, every last bit of layout logic should be in your CSS.</p> <p>Good luck!</p> <p><img src="https://i.stack.imgur.com/ZYaiz.jpg" alt="enter image description here"> </p> <p><img src="https://i.stack.imgur.com/ghlOv.jpg" alt="enter image description here"></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; html { height: 100%; min-height: 100%; font-size: 100%; } body { margin: 0; height: 100%; min-height: 100%; } header { background-color: #FF0000; float: left; /* if you want a layout with floated descendants... */ position: absolute; width: 100%; top: 0; overflow: hidden; height: 4.6em; border-bottom: 0.15em solid yellow; } article { background-color: #CCCCCC; float: left; position: absolute; width: 100%; top: 4.75em; bottom: 2.75em; overflow: auto; } footer { background-color: #AACCFF; float: left; position: absolute; width: 100%; height: 2.75em; bottom: 0; border-top: 0.15em solid blue; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;header&gt; Header Stuff... &lt;/header&gt; &lt;article&gt; Resize shorter vertically to see what happens when the content overflows.&lt;br/&gt; 1&lt;br/&gt; 2&lt;br/&gt; 3&lt;br/&gt; 4&lt;br/&gt; 5&lt;br/&gt; 6&lt;br/&gt; 7&lt;br/&gt; 8&lt;br/&gt; 9&lt;br/&gt; 10&lt;br/&gt; 11&lt;br/&gt; 12&lt;br/&gt; 13&lt;br/&gt; 14&lt;br/&gt; &lt;/article&gt; &lt;footer&gt; Footer stuff... &lt;/footer&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    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.
    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