Forum Moderators: not2easy

Message Too Old, No Replies

2 column layout - using borders and margins

IE 6 does not show column content

         

J64sqs

4:52 pm on Apr 2, 2005 (gmt 0)

10+ Year Member



I'm trying to do a 2 column layout using borders and margins. But, when I view the page in IE6, the left column (id="sidebar") does not show up. The color shows up, but the actual content is not visible. Please help. My basic code looks like...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert Title Here</title>
<style type="text/css">
body {
margin:0;
padding:0;
background-color:#4d74df;
}
#container {
background-color:#ffcc66;
border-left:220px solid #2121b0; /*to create column effect*/
margin:0;
padding:0;
}
#header {
background-color:#4d74df;
margin-left:-220px;
}
#mainNav {
background-color:#2121b0;
border-top:2px solid navy;
padding-left:220px;
color:#d7d7d7;
}
#sidebar {
background:#2121b0;
width:220px;
float:left;
margin-left:-220px;
padding:0;
color:#d7d7d7;
}
#content {
background-color:#ffcc66;
padding:1em;
border-top:2px solid navy;
border-left:2px solid navy;
border-bottom:2px solid navy;
}
#footer {
background-color:#4d74df;
color:#d7d7d7;
margin-left:-220px;
clear:both;
}
</style>
</head>
<body>
<div id="container">
<div id="header">
Header
<div id="mainNav">
Main Navigation
</div>
</div>
<div id="sidebar">
Sidebar
<div id="sectionNav">
Section Navigation
</div>
</div>
<div id="content">
<p>This is the content area</p>
</div>
<div id="footer">
Footer here
</div>
</body>
</html>

Moby_Dim

5:32 pm on Apr 2, 2005 (gmt 0)

10+ Year Member



Remove floating of this element, and it'd be OK I suppose.

And count <div's and </div's on the page too ;)

J64sqs

6:04 pm on Apr 2, 2005 (gmt 0)

10+ Year Member



sorry, there should be another </div> before </body>.

But if I take out the float, then everything would be one column.

Moby_Dim

6:23 pm on Apr 2, 2005 (gmt 0)

10+ Year Member



>>But if I take out the float, then everything would be one column.

Sure, one only. Look - you have 'sectionNav' element but it is not defined in your style section.

J64sqs

6:36 pm on Apr 2, 2005 (gmt 0)

10+ Year Member



Sorry for confusion. Here is corrected code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert Title Here</title>
<style type="text/css">
body {
margin:0;
padding:0;
background-color:#4d74df;
}
#container {
background-color:#ffcc66;
border-left:220px solid #2121b0; /*to create column effect*/
margin:0;
padding:0;
}
#header {
background-color:#4d74df;
margin-left:-220px;
}
#mainNav {
background-color:#2121b0;
border-top:2px solid navy;
padding-left:220px;
color:#d7d7d7;
}
#sidebar {
background:#2121b0;
width:220px;
float:left;
margin-left:-220px;
padding:0;
color:#d7d7d7;
}
#content {
background-color:#ffcc66;
padding:1em;
border-top:2px solid navy;
border-left:2px solid navy;
border-bottom:2px solid navy;
}
#footer {
background-color:#4d74df;
color:#d7d7d7;
margin-left:-220px;
clear:both;
}
</style>
</head>
<body>
<div id="container">
<div id="header">
Header
<div id="mainNav">
Main Navigation
</div>
</div>
<div id="sidebar">
Sidebar
</div>
<div id="content">
<p>This is the content area</p>
</div>
<div id="footer">
Footer here
</div>
</div>
</body>
</html>

Moby_Dim

6:45 pm on Apr 2, 2005 (gmt 0)

10+ Year Member



still floating... ;)

J64sqs

10:50 pm on Apr 2, 2005 (gmt 0)

10+ Year Member



If I delete the float, then the "sidebar" and "content" divs will not be next to each other. But I want them to be next to each other. So, don't I need to keep the float?