views:

432

answers:

3

Having a world of trouble with a fullscreen layout. Either a table or css based solution would be appreciated.

The goal is to expand to the viewing screen, with the "nav" fixed by width and "top" fixed by height, ideally without javascript. The code below works until the "content" fills up. When that happens it needs to scroll. However, the overflow on the td doesn't work. Neither does wrapping it around a div with overflow. I think this has to do with tables auto expanding to fit the content div. However, since the content div needs to stretch to the screen, it can't have a fixed height.

 <table style="width: 100%; background: blue; height: 100%">
  <tr>
   <td id="nav" style="width: 200px; background: yellow"></td>

   <td style="background: green">
    <table style="width: 100%; height: 100%; background: purple">
     <tr>
      <td id="top" style="height: 200px; background: orange"></td>
     </tr>
     <tr>
      <td id="content" style="background: gray; overflow-y: auto">
      </td>
     </tr>
    </table>
   </td>
  </tr>

 </table>
A: 

I found that this css layout, partially dubbed the "sticky footer" has been the best layout, that is simple, and will easily expand or contract based on your content.

Dillie-O
A: 

Yeah, I've had this problem with Firefox in particular. Safari does this pretty well (including with min-height) but all other browsers can't do it.

The way I was able to do it is to force a specified px height onload and on refresh using, yeah, Javascript. It's tough to do it cross-platform without it.

Mark
A: 

You really should not be trying to layout using tables.

Here is some code I whipped up to get 100% height with no tables:

<html>
<head>
    <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css"&gt; 
    <style type="text/css">
        #wrapper {
            height: 100%;
            width: 100%;
        }
        #column1 {
            position: absolute;
            top: 0;
            left: 0;
            width: 200px;
            height: 100%;
            overflow: hidden;
        }
        #column2 {
            position: absolute;
            top: 0;
            left: 200px;
            height: 100%;
            overflow: hidden;
        }
        #row1 {
            height: 200px;
            overflow: hidden;
        }
        #row2 {
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div id="wrapper">
        <div id="column1" style="background-color: yellow;">
            bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah 
            bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
            bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
            bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
            bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
            bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
            bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
            bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
        </div>
        <div id="column2">
            <div id="row1" style="background-color: orange;">
                bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
            </div>
            <div id="row2" style="background-color: grey;">
                bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah bwah 
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
                bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>bwah<br>
            </div>
        </div>
    </div>
</body>
</html>
John Scipione