I am trying to get to grips with CSS (it having been an aspect of dev that I have tried to avoid in the past) but I cannot get my head around what is going on here.
The Aim
- Have a 2 column layout, always at least full page height, but grows if the content dictates
EDIT: Both columns should be equal height, too i.e. both grow to largest.
Problem
When the content is less than a page, it remains at full height as is my intention. However in a situation like the fiddle below where the content is longer than a page, whilst the page scrolls, the backgrounds do not flow with the content.
JSFiddle http://jsfiddle.net/tDSAg/
HTML
<header>
<div class="header-inner">Header</div>
</header>
<div id="outer">
<div class="col1">
<p>Start</p>
<p>Col1</p>
<p>End</p>
</div>
<div class="col2">
<p>Start</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>Col2</p>
<p>End</p>
</div>
CSS
html, body
{
height: 100%;
}
#outer
{
min-height: 100%;
background-color: red;
height: 100%;
width: 1000px;
margin-left: auto;
margin-right: auto;
}
.col1
{
background-color: green;
width: 220px;
float: left;
min-height: 100%;
height: 100%;
margin-right: 10px;
}
.col2
{
background-color: aliceblue;
width: 770px;
float: left;
min-height: 100%;
height: 100%;
}
header {
background-color: orange;
}
.header-inner {
width: 1000px;
margin-left: auto;
margin-right: auto;
}