views:

644

answers:

2

So I am trying to replicate this in IE6: http://lynet.ca/~alumb/layout.html
It works perfectly in FF and Chrome, but fails miserably in IE6. Any suggestions?

Here is the full set of requirements:

+-----------------------------+
| NavBar                      |
|-----------------------------|
|Menu | Content               |
|     |                       |
|     |                       |
|     |                       |
|     |                       |
|     |                       |
|     |                       |
+-----------------------------+
  • NavBar is a set height in EM (say 2em)
  • Menu is a set width in EM (say 10em) and fills to the bottom of the page
  • There should be no global page scrollbar
  • menu must scroll in place and not cover the navbar (like overflow:scroll)
  • content is an iFrame that fills the full space available.
  • layout must survive resising the browser

I have tried css, but it results in a crazy amount of css and I still can't get the iframe to fill the space correctly.
I have tried tables, but I can't get the menu to scroll in the right way.
The only solution I have involves frames, but this is not really the route I want to go.


Solution:
So after about 36 hours of bashing at it, I finally have a solution. The only way I could get this to work was with table based layouts. However, there is a quirk in Firefox that causes height:100% to be calculated differently than in every other browser, so I also had to add the position:fixed styling. This is mostly ignored by IE6 which falls back on the table based layout.

An example of the final layout can be seen here: http://lynet.ca/~alumb/working.html

A: 

It's hard to mix dimensions particularly vertically with CSS. The navbar is 2 ems high and the menu is 100% - 2ems high - this last height is difficult to do with pure CSS. You may need to calculate it with JavaScript.

An alternate solution is to make the page behave like a normal webpage was designed to do (all scroll in one piece). Here is an example layout that might help: Left menu layout (em widths)

Matthew James Taylor
for various reasons I can't do this, as much as I would like to. The set of requirements is fixed.
alumb
+2  A: 

The solution is easy. Use absolute positioning.

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#NavBar {
}


#Menu, #Content {
    position: absolute;
    top: 3em;
    bottom: 0;
    overflow: auto;
}

#Menu {
    width: 10em;
}

#Content {
    overflow: hidden;
    left: 10em;           /* #menu.width */
    right: 0;
}

iframe {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
}

For IE to work, make sure you set your doc type. For example, insert this at the top of your HTML file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
strager
Doesn't work. You end up with this: http://lynet.ca/~alumb/strager.html
alumb
@alumb, Updated.
strager
updated http://lynet.ca/~alumb/strager.html. still doesn't work.
alumb
@alumb, One more update (overflow on body). I think the issue is caused by the iframe's borders.
strager
@strager, I don't think I'm seeing what you are seeing. I see this: http://lynet.ca/~alumb/strager.jpg. The word 'bottom' should be at the bottom of the page. I also updated the strager.html file. Thanks for helping.
alumb
@alumb, Grr, I wasn't testing in IE as I should have been. Updated answer.
strager
@strager, ok, Now I'm getting some weird problem where in IE6, the iframe disappears completely if its position is set to absolute.
alumb
@strager, This is a hasLayout problem. I have to set the height and width of #content and body. however, the iframe's 100% height is still relative to the body and not #container thus overflowing the page.
alumb