Forum Moderators: not2easy

Message Too Old, No Replies

100% height table and columns

display: table

         

jangrzdyl

5:04 pm on Feb 10, 2011 (gmt 0)

10+ Year Member



Hello,

I have 3 divs with height:100% of screen. If one of them is heigher then two remaining divs does not extending. Wrapper of them have to be centered. Here is the code of my example:


<html>
<head>
</head>
<body style="height:100%;">
<div style="margin-left:auto; position:relative; margin-right:auto; width:960px; height:100%; border:1px solid black;">
<div style="display:table-cell; min-height:100%; height:auto; width:100px;float:left;border:1px solid green;">
1
</div>
<div style="display:table-cell; min-height:100%;height:auto;float:left;border:1px solid black;">
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>huj<br>
</div>
<div style="display:table-cell; min-height:100%;height:auto; width:100px; float:right;border:1px solid black;">
3
</div>
</div>
</body>
</html>


I will be grateful of any help.
Best regards,
Jan Grzdyl

[edited by: alt131 at 8:17 pm (utc) on May 17, 2011]
[edit reason] Side Scroll [/edit]

alt131

6:04 am on Feb 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Jan, and welcome to WebmasterWorld ;)

As I understand your code, you want the table to always 100% of the viewport tall, even if the columns don't extend that far down, and you want all the columns to be 100% the height of the table?
If I have that right, couple of changes should do it:

body {min-height:100%;}

The wrapper div (currently starting with "margin-left:auto;", set to
display:table; <-- this makes it behave "table-like" and expand to contain contents
height:100%; <-- make it the 100% height of body
margin: 0 auto; <-- shorthand for you existing margin declarations
width:960px; border:1px solid black <-- what you already have

The column divs
display:table-cell;
height:100%; <-- make them 100% height of the table
width:100px;
float:left; <-- adjust to suit
border:1px solid green <--adjust to suit