tags:

views:

85

answers:

2

Given the following code, how can I make the height of wrapper div extend all the way down.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<style type="text/css">
.wrapperDiv {
    position: relative;
    width: 800px;
    background-color: #FFFF00;
    margin-right: auto;
    margin-left: auto;
}
.content {
    position: absolute;
    width: 95%;
    top: 55px;
    background-color: #008000;
}
.footer {
    position: absolute;
    width: 95%;
    height: 50px;
    background-color: #FF00FF;
    bottom: 5px;
}
.header {
    position: absolute;
    width: 95%;
    height: 50px;
    background-color: #CCFF33;
    top: 5px;
}
</style>
</head>

<body>

<div id="wrapper" class="wrapperDiv">
    <div id="layer2" class="footer">
     3</div>
    <div id="layer3" class="header">
     1</div>
    <div id="layer1" class="content">
     2<br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     END</div>
</div>

</body>

</html>
A: 

Add this:

html, body, .wrapperDiv {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
}

You will then have problems with your wrapperDiv being wider than the divs it contains. Not sure what you want to do about that.

cletus
Thanks for your reply, I couldn't get the problem solved ended up using a background image.
ace
A: 

You can use javascript to get the offsetheight of the absolute element and add it to the height of your parent div.

George Sisco
Thanks for your reply, I couldn't get the problem solved ended up using a background image.
ace