views:

163

answers:

2

Is it possible? div "menu" and "submenu" needs to be 50px tall. "top" and "bottom" needs to be 60% and 40%. The behinde-the-scene-calculation would be 60% - 50px for "top".

<div id="menu"></div>
<div id="top">
</div>
<div id="submenu"></div>    
<div id="bottom">
</div>
+1  A: 

As you asking if you can do this? Because yes, you can

#menu, #submenu{
    height: 50px;
}
#top{
    height: 60%;
}
#bottom{
    height: 40%;
}

What would happen is both menus would be 50px, and then the top and bottom would take 60 and 40% of the page. Most likely you would have scrollbars because the page would be 100px over 100% of the page, but it is very possible.

You can mix percentages, pixels, and ems.

Chacha102
Although, the top and bottom as the code you wrote would take up 60 and 40 percent of the page. But it is very possible to do that.
Chacha102
You know that is not what he meant. He wants wants to divide the space remaining from header and footer 3:2.
buti-oxa
buti-oxa, thats right!
Andersson
If you want the entire thing to only equal 200px, just put it inside a div that have the height set to be 200px. Still not sure about the question though.
Chacha102
+1  A: 

CSS doesn't mix units to let you say 60% - 50px -- to achieve something like this effect, you'd have to resort to JavaScript to compute the sizes.

If your div's are directly inside , you won't have to re-implement too much of a layout engine -- at document load, get the viewport size, then compute what 60% - 50px is in pixels and assign that as the #top element height, and similarly for #bottom.

Steve Gilham
To solve it with JavaScript you have to compute when the window resizes. Not only on document load. Thats my last option. Rather go with frames...
Andersson