Forum Moderators: not2easy

Message Too Old, No Replies

Height problem with nested div

I want 20% in nest, it gives 100%

         

joolsm

9:31 am on Jun 30, 2004 (gmt 0)

10+ Year Member



I'm sure that I'm missing something obvious here in my css and hope someone can help.

Left column is 100% height div contained within 100% height outer div (both on main stylesheet) and contains div for menu (which has separate stylesheet)

Css for left column div is

float: left;
padding: 0px;
z-index: 1;
vertical-align: top;
text-align: left;
width: 17%;
height: 100%;

CSS for menu div is
font-family: Arial, Verdana, sans-serif;
height: 20%;
background-color: #ffffff;
border: 2px #000080 solid;
font-size: 100%;
margin-top: 0px;
margin-bottom: 0px;
margin-right: 0px;
padding: 0px;
margin-left: 5px;
width: 95%;
vertical-align : top;

In order to retain page layout, the left column has to retain 100% height. My problem is with the menu which also retains 100% height, regardless of whether I set height to auto or a value such as 20%. I don't want the menu the full height of its containing div - what have I got wrong in the above that it won't give me the 20% height I want?

Many thanks, Jools

MatthewHSE

1:06 pm on Jun 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just thinking off the top of my head, try floating the menu div left. Might not have any effect, but floats can be tricky depending on what browser and doctype you're using. (What are you using, by the way?)

Also, is it necessary that it be given a height at all? Would it be sufficient to just let the height be auto to accomodate whatever content you put in it?

Rambo Tribble

1:16 pm on Jun 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I doubt it has any bearing on your problem, but vertical-align is only appropriate for inline elements and table cells.

DrDoc

1:24 pm on Jun 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe some markup could assist in pinpointing the problem?

SuzyUK

1:51 pm on Jun 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



joolsm

can't see any problems with what's here, I tried a quick mockup with the code you give and it's giving the menu 20% height

here's what I used.. post your code if there's differences


<style type="text/css" media="screen">
html, body {
margin: 0;
padding: 0;
height: 100%;
}

#left {
background: #ff0;
float: left;
padding: 0px;
width: 17%;
height: 100%;
}

#menu {
height: 20%;
background: #fff;
border: 2px solid #000080;
margin: 0 0 0 5px;
padding: 0;
width: 95%;
}
</style>
</head>
<body>
<div id="left">
<div id="menu">menu</div>
</div>
</body>
</html>

Suzy