Reputation: 42574
I'm trying to achieve the following layout without success:
The requirements are:
This is easy as cake using tables, except for the third requirement, but I just can't manage to do it using DIVs and CSS. The closest thing I've found is "The Perfect 3 Column Liquid Layout (Percentage widths)", but it has percentage widths, which doesn't suit what I need.
Upvotes: 2
Views: 1671
Reputation: 256
This is easily doable nowadays with flex-box.
Here you go. All your 3 requirements are met without a single use of the properties width
or height
. All containers adjust to their content.
body {text-align:center; font: 16px arial}
wrap {display: inline-flex; flex-direction: column; background: lightgrey;}
header {margin-bottom: 10px; background: white; }
footer {margin-top: 10px; background: white}
content {display: flex; flex-direction: row-reverse}
ctnr {display: flex;}
centerCol {margin: 0 10px; background: green}
rightCol {background: blue}
leftCol {background: red}
[pad] {padding: 10px; border: 1px solid black;}
<wrap pad>
<header pad>Header</header>
<content>
<ctnr>
<centerCol pad><br><br><br>Center column<br><br><br><br><br><br><br></centerCol>
<rightCol pad>Right</rightCol>
</ctnr>
<ctnr>
<leftCol pad>Left</leftCol>
</ctnr>
</content>
<footer pad>Footer</footer>
</wrap>
Upvotes: 1
Reputation: 175
i found how to put the the center column first in the code
http://jsfiddle.net/gamepreneur/bj6bU/
html
<div class="main">
<div class="right-float">
<div class="green">
green
</div>
<div class="blue">
blue
</div>
</div>
<div class="red">
red
</div>
</div>
css
.right-float {
float:right
}
.green {
float:left;
}
.blue {
float:right
}
.red {
float:left;
}
I'm just not sure how to do the rest... plus it's 12:40pm (at the time that i am writing this)
Upvotes: 0