Forum Moderators: not2easy
float: leftand float: right respectively. Below the container I got another div, divC. height: 100%.
position: relative;
height: 100%;
width: 940px;
position: relative;
height: 100%;
float: left;
width: 700px;
background-color:#ffffff;
position: relative;
height: 100%;
float: right;
width: 220px;
background-color: #f0f0f0;
float:both;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
html, body {
margin:0;
padding:0;
background:#ccc;
color:#000;
}
p, h1 { margin:0 0 1em }
.wrapper {
position: relative;
width: 940px;
margin:auto;
overflow:hidden;
}
.main, .l {
position: relative;
z-index:2;
float: left;
width: 700px;
background-color:#ffffff;
padding:1px 0;
}
.sidebar, .r {
position: relative;
z-index:2;
float: right;
width: 220px;
background-color: #f0f0f0;
padding:1px 0;
}
.r, .l {
position:absolute;
top:0;
right:0;
bottom:0;
width:220px;
z-index:1;
padding:0;
}
* html .1, * html .r {/* ie6 fix*/
top:auto;
bottom:0;
height:9999em;
}
.l {
width:700px;
left:0;
right:auto;
}
.footer {
clear:both;
width:940px;
margin:auto;
background:red;
padding:1px 0;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="main">
<h1>Main Content</h1>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
</div>
<div class="sidebar">
<p>Sidebar content</p>
</div>
<div class="l"></div>
<div class="r"></div>
</div>
<div class="footer">
<p>Footer content</p>
</div>
</body>
</html>
.main, .l {...}, where position is set to relative .r, .l {...}, where position is set to absolute .l {...}
1. It appears to me as if you are re-assigning styles to .r and .l throughout the CSS. For .l you first have
.main, .l {...}, where position is set to relative
then
.r, .l {...}, where position is set to absolute
and finally only
.l {...}
Any hints on how that works? Or any reading directions?
.main, .l {
position: relative;
z-index:2;
float: left;
width: 700px;
background-color:#ffffff;
padding:1px 0;
}
.r, .l {
position:absolute;
top:0;
right:0;
bottom:0;
width:220px;
z-index:1;
padding:0;
}
* html .1, * html .r {/* ie6 fix*/
top:auto;
bottom:0;
height:9999em;
}
.l {
width:700px;
left:0;
right:auto;
}
.main{
position: relative;
z-index:2;
float: left;
width: 700px;
padding:1px 0;
}
.l {
position:absolute;
top:0;
left:0;
bottom:0;
width:700px;
z-index:1;
width:700px;
background-color:#fff;
}
* html .l{/* ie6 fix - using the "* html" hack */
top:auto;
bottom:0;
height:9999em;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
html, body {
margin:0;
padding:0;
background:#ccc;
color:#000;
}
p, h1 { margin:0 0 1em }
.wrapper {
position: relative;
width: 940px;
left:10px;
overflow:hidden;
background-color:#ffffff;
}
.main {
position: relative;
z-index:2;
float: left;
width: 700px;
padding:1px 0;
}
.sidebar {
position: relative;
z-index:2;
float: right;
width: 220px;
background-color: #f0f0f0;
padding:1px 0;
}
.l {
position:absolute;
top:0;
left:0;
bottom:0;
width:700px;
z-index:1;
width:700px;
background-color:#fff;
}
.r {
position:absolute;
top:0;
right:0;
bottom:0;
width:220px;
z-index:1;
padding:0;
background-color: #f0f0f0;
}
* html .1, * html .r {/* ie6 fix*/
top:auto;
bottom:0;
height:9999em;
}
.footer {
clear:both;
width:940px;
position: relative;
left: 10px;
background:red;
padding:1px 0;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="main">
<h1>Main Content</h1>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
</div>
<div class="sidebar">
<p>Sidebar content</p>
</div>
<div class="l"></div>
<div class="r"></div>
</div>
<div class="footer">
<p>Footer content</p>
</div>
</body>
</html>