I cooked up a 2-column, liquid layout based on "float" (code follows). But can't seem to get rid of the vertical space between columns 1 and 2. Results vary with browser: IE 5/6 leaves wide space, Opera 7 just a 1px space, Mozilla renders properly.
Anybody know how to fix it?
==================== BEGIN CSS ====================
/*** 2-column liquid CSS layout using floats ***/
/*** BEGIN CSS ***/
/*** HTML tag styles ***/
body{
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #333333;
line-height: 140%;
margin: 0px;
padding: 0px;
background-color: #66517B; /* */
font-size: 76%;
}
h1 {
font-size: 200%;
}
ul{
list-style-type: square;
}
ul ul{
list-style-type: disc;
}
/*** Format Classes ***/
.subhead {
margin:0px; /* For first element in column, set top margin to zero to fix IE 5/6, Opera 7 rendering error. Without fix, vertical alignment of content elements may not line up column to column */
font-weight: bold;
color: #000000;
font-size: 1.4em;
font-family: Arial, Helvetica, sans-serif;
}
/*** Layout Divs ***/
#wrapper{
margin: 10%;}
#masthead{
padding: 2%;
background-color: #3399CC;
margin: 0px;
}
#left-column{
padding: 2%;
width:20%;
float: left;
margin: 0px;
background-color: #FFBEA8;
}
#center-column{
padding: 2%;
margin-left: 24%;
background-color: #D2D2FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
/* Clearing the footer (clear:both, expands the footer to full width
and places it immediately under the longest column. */
#footer{
clear: both;
font-size: 100%;
color: #000000;
padding: 2%;
background-color: #77BCDD;
text-align: center;
}
#footer img{
padding: 0px;
}
/*** END CSS ***/
==================== END CSS ====================
==================== BEGIN HTML ====================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
<html xmlns=" <head>
<meta name="generator" content="HTML Tidy, see />
<title>3-Column CSS Layout</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="2-column.3.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<!-- start masthead -->
<div id="masthead">
<h1>Masthead</h1>
<span class="subhead">Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Donec molestie. Sed aliquam sem ut arcu.</span>
</div>
<!-- start left-column -->
<div id="left-column">
<p class="subhead">Column 1</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
molestie.</p>
</div>
<div id="center-column">
<p class="subhead">Column 2</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
molestie. Sed aliquam sem ut arcu. Phasellus sollicitudin. orem ipsum
dolor sit amet, consectetuer adipiscing elit. Donec molestie. Sed
aliquam sem ut arcu. Phasellus sollicitudin. Lorem ipsum dolor sit
amet, consorem ipsum dolor sit amet, consectetuer</p>
<p>Lorem ipsum dolor sit amet, consorem ipsum dolor sit amet,
consectetuer allus sollicitudin. orem ipsum dolor sit amet,
consectetuer adipiscing elit.</p>
</div>
<!-- start footer -->
<div id="footer">
<span class="subhead">Footer</span><br />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</div>
</div>
</body>
</html>
==================== END HTML ====================
Anybody know how to fix it?
==================== BEGIN CSS ====================
/*** 2-column liquid CSS layout using floats ***/
/*** BEGIN CSS ***/
/*** HTML tag styles ***/
body{
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #333333;
line-height: 140%;
margin: 0px;
padding: 0px;
background-color: #66517B; /* */
font-size: 76%;
}
h1 {
font-size: 200%;
}
ul{
list-style-type: square;
}
ul ul{
list-style-type: disc;
}
/*** Format Classes ***/
.subhead {
margin:0px; /* For first element in column, set top margin to zero to fix IE 5/6, Opera 7 rendering error. Without fix, vertical alignment of content elements may not line up column to column */
font-weight: bold;
color: #000000;
font-size: 1.4em;
font-family: Arial, Helvetica, sans-serif;
}
/*** Layout Divs ***/
#wrapper{
margin: 10%;}
#masthead{
padding: 2%;
background-color: #3399CC;
margin: 0px;
}
#left-column{
padding: 2%;
width:20%;
float: left;
margin: 0px;
background-color: #FFBEA8;
}
#center-column{
padding: 2%;
margin-left: 24%;
background-color: #D2D2FF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
/* Clearing the footer (clear:both, expands the footer to full width
and places it immediately under the longest column. */
#footer{
clear: both;
font-size: 100%;
color: #000000;
padding: 2%;
background-color: #77BCDD;
text-align: center;
}
#footer img{
padding: 0px;
}
/*** END CSS ***/
==================== END CSS ====================
==================== BEGIN HTML ====================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
<html xmlns=" <head>
<meta name="generator" content="HTML Tidy, see />
<title>3-Column CSS Layout</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="2-column.3.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<!-- start masthead -->
<div id="masthead">
<h1>Masthead</h1>
<span class="subhead">Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Donec molestie. Sed aliquam sem ut arcu.</span>
</div>
<!-- start left-column -->
<div id="left-column">
<p class="subhead">Column 1</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
molestie.</p>
</div>
<div id="center-column">
<p class="subhead">Column 2</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
molestie. Sed aliquam sem ut arcu. Phasellus sollicitudin. orem ipsum
dolor sit amet, consectetuer adipiscing elit. Donec molestie. Sed
aliquam sem ut arcu. Phasellus sollicitudin. Lorem ipsum dolor sit
amet, consorem ipsum dolor sit amet, consectetuer</p>
<p>Lorem ipsum dolor sit amet, consorem ipsum dolor sit amet,
consectetuer allus sollicitudin. orem ipsum dolor sit amet,
consectetuer adipiscing elit.</p>
</div>
<!-- start footer -->
<div id="footer">
<span class="subhead">Footer</span><br />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</div>
</div>
</body>
</html>
==================== END HTML ====================