Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get css div to stretch to 100% of window

Tags:

html

css

I'm having difficulty achieving this. I would like the div content1 and content2 to fill up the remaining space vertically in a window with a set minimum height.

<style type="text/css">
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    height:100%;
}
body {
    background-color: #E1E1E1;
}
</style>
<style type="text/css">
.container {
    width: 965px;
    height: 100%;
    margin: 0 auto; 
    overflow: hidden;
}
.sidebar1 {
    float: left;
    width: 200px;
    background: none;
    padding-bottom: 10px;
} .content {
    padding: 10px 0;
    width: 380px;
    height: 100%;
    background: #fff;
    float: left;
    position: relative;
} .content2 {
    float: left;
    width: 380px;
    height: 100%;
    background: #fff;
    padding: 10px 0;
}
-->
</style>

Here are the divs I'm trying to resize (currently empty but I would like them to fill up the window vertically):

<div class="content" style="border-left: solid 1px #CCC;"></div>
<div class="content2"><!-- end .sidebar2 --></div>
like image 614
methuselah Avatar asked Feb 02 '11 04:02

methuselah


1 Answers

You need 100% height on the html tag as well

html { height: 100%; }

See: http://jsfiddle.net/wJ73v/

like image 91
Petah Avatar answered Oct 01 '22 15:10

Petah