I need to sharpen my html/css skills as they're not that great at the moment so I've come up with a website I want to make and I just started with the layout today. For the life of me though I can't get everything positioned where I want it though. It doesn't work in either the latest Chrome, Firefox 12 or IE9. Layout is ok in IE7 mode in IE9 though. Something to do with the wrong use of absolute and relative positioning is my guess.
The header should always be at the top and the footer at the bottom. The middle section should adjust in height according to the size of the biggest column inside it (currently one column with a nav in it and then another with the main content of the page). The min-height of the middle area is intentional so the side nav isn't cut off ever. The footer should lie underneath the middle area always.
It's just something I've been experimenting with today so the naming isn't the best and there might be some superfluous css in there, but hopefully the answer to my problem is pretty straight forward. Been a bit trial and error so far with no success. Here's the code:
Firebug tells me that the "content" div is spilling outside of the "middle" div which is not what I want. Any ideas?
The header should always be at the top and the footer at the bottom. The middle section should adjust in height according to the size of the biggest column inside it (currently one column with a nav in it and then another with the main content of the page). The min-height of the middle area is intentional so the side nav isn't cut off ever. The footer should lie underneath the middle area always.
It's just something I've been experimenting with today so the naming isn't the best and there might be some superfluous css in there, but hopefully the answer to my problem is pretty straight forward. Been a bit trial and error so far with no success. Here's the code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div id="container-outer">
<div id="container-inner">
<div id="header">
<div id="masthead">
</div>
<div id="top-nav">
</div>
</div>
<div id="middle">
<div id="left-column">
<div id="left-nav">
<p>Navigation</p>
<p>Navigation</p>
<p>Navigation</p>
<p>Navigation</p>
<p>Navigation</p>
</div>
</div>
<div id="content">
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
</div>
</div>
<div id="footer">
<p>Footer</p>
</div>
</div>
</div>
</body>
</html>
Code:
#container-outer
{
background-color:#ffffff;
}
#container-inner
{
background-color:#c0c0c0;
width: 976px;
position: relative;
margin: auto;
}
#header
{
position: relative;
width: 100%;
height: 50px;
}
#masthead
{
position: relative;
height: 30px;
top: 0;
background-color: #800000
}
#top-nav
{
position: relative;
height: 20px;
bottom: 0;
background-color: #ffe4c4
}
#middle
{
position: relative;
background-color: #ffffff;
min-height: 320px;
width: 976px;
}
#left-column
{
background-color:#ff0000;
width: 100px;
height: 300px;
position: relative;
float: left;
}
#content
{
background-color: #00ff00;
width: 800px;
position: relative;
right: 0px;
float: right;
}
#footer
{
background-color: #ffff00;
width: 100%;
height: 100px;
position: relative;
bottom: 0px;
}
body, p
{
margin: 0;
padding: 0;
}
Firebug tells me that the "content" div is spilling outside of the "middle" div which is not what I want. Any ideas?