Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is one approach that uses CSS only.</p> <p>The HTML looks like:</p> <pre><code>&lt;div id="pageWrapper"&gt; &lt;header&gt;Header&lt;/header&gt; &lt;div id="contentWrapper"&gt; &lt;div class="table-wrap"&gt; &lt;div class="cell col1"&gt; &lt;div class="content"&gt;Column 1: Shrink-to-Fit Width&lt;/div&gt; &lt;/div&gt; &lt;div class="cell col2"&gt; &lt;div class="content"&gt;Column 2: Variable Width&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="footerWrapper"&gt;Footer&lt;/div&gt; &lt;/div&gt; </code></pre> <p>and the CSS:</p> <pre class="lang-css prettyprint-override"><code>html, body { height: 100%; margin: 0; } body { background-color: #E3E3E3; } #pageWrapper { margin: 0 auto; position: relative; width: 90%; /*set to 100% or smaller or fixed width... */ height: 100%; } header { display:block; width: 100%; height: 100px; background: yellow; } #contentWrapper { width: 100%; position: absolute; top: 100px; bottom: 100px; left: 0; background: beige; } #footerWrapper { width: 100%; position: absolute; height: 100px; bottom: 0px; left: 0; background: gray; } .table-wrap { width: 100%; height: 100%; } .table-wrap .cell { height: 100%; } .table-wrap .col1 { float: left; border: 1px dotted blue; max-width: 80%; /* This is critical or else Column 2 can disappear */ } .table-wrap .col1 .content { height: inherit; display: inline-block; overflow-y: auto; } .table-wrap .col2 { } .table-wrap .col2 .content { height: inherit; overflow-y: auto; } </code></pre> <p>See demo at: <a href="http://jsfiddle.net/audetwebdesign/kbAwf/" rel="nofollow">http://jsfiddle.net/audetwebdesign/kbAwf/</a></p> <h2>How This Works</h2> <p>Use absolute positioning to place the header, main content area and footer within the view port area.</p> <p>Within the content area (<code>#contentWrapper</code>), the <code>.table-wrap</code> container has two cells, one which is floated left (column 1). This allows column 2 to fill the rest of the width.</p> <p>To get the shrink-to-fit width for column 1, set <code>display: inline-block</code> to the inner <code>.content</code> container.</p> <p>Finally, use <code>overflow-y: auto</code> for the scroll bars. (You can also use the scroll value.)</p> <p>You need to set a maximum width to <code>.col1</code> so that <code>.col2</code> does not get pushed out of the view port. I set it to 80% but you can adjust it.</p> <p>Also, note that an inline-block will expand as much as possible to flow its content, which is why you need to constrain it.</p> <p>You man want to set a minimum width on <code>#pageWrapper</code> to prevent the layout from shrinking to something that is less than useful.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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