Possible Duplicate:
CSS - percentage height
I can't get the middle div of 3 divs to fit 100% of available space.
<body>
<div id="container">
<div id="header">
</div>
<div id="content">
</div>
<div id="footer">
</div>
</div>
</body>
My CSS is:
html, body {
margin: 0;
padding: 0;
border:1px;
vertical-align:top;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:14px;
color:#333;
height: 100%;
}
#container {
height: 100%;
width: 100%;
}
#header {
height: 100px;
width: 100%;
background: #069;
}
#content {
height: 100%;
width: 100%;
background: #F60;
}
#footer {
height: 75px;
width: 100%;
background: #060;
}
Center div is in effect being 100%, but its not fitting available space.
It is doing something like this: If the screen is 500px
30px
100% (500px)
30px
What I need is:
30px
100% (460px)
30px
Is this possible withouth using javascript?
Thanks a lot
EDIT:
Sorry I meant Height I have 3 elements, header, middle and footer. Header and footer have fixed height, but I want middle to fit all available space
Found another solution based on other stackoverflow question:
* { margin: 0; padding: 0 }
html, body {
margin: 0;
padding: 0;
vertical-align:top;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:14px;
color:#333;
height: 100%;
border: 0;
}
#header
{
height: 100px;
background:#C60;
}
#container
{
min-height: 100%;
height: auto !important; /*Cause footer to stick to bottom in IE 6*/
height: 100%;
margin: 0 auto -100px; /*Allow for footer height*/
vertical-align:bottom;
background:#096;
}
#footer
{
height: 100px; /*Push must be same height as Footer */
background:#C60;
}
HTML
<body>
<div id="container">
<div id="header"> </div>
<div id="content"> </div>
</div>
<div id="footer"> </div>
</body>
You could position the div absolutely:
and
I think that a good idea would be to fiddle with 'display:flexbox' to achieve that kind of responsiveness. Here is a good article about it.
Try something like this jsfiddle.
html
css
I tweaked your HTML to add a "wrapper" around the "container" div, and move the "footer" out of both.