PDA

View Full Version : Extra Space Between Container and Child DIVs


The Autumn Window
04-21-2009, 09:46 AM
Website: www.theautumnwindow.com (http://www.theautumnwindow.com)

Browsers: FF 3, Opera 9, Safari 4

There is a bit of white space (container bgcolor is white) between the container and the child DIVS and I don't know why. Margins and pads are set to 0px.

What is going on and how do I fix it?


HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>T.A.W. Site - Under Construction</title>
<link rel="stylesheet" type="text/css" href="maincss.css" />
<link rel="shortcut icon" href="Images/favicon.ico" />
</head>

<body class="thrColLiq">

<div id="container">
<div id="sidebar1">
<br /><br />
<div align="center">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" width="290" height="350" id="TwitterWidget" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="http://static.twitter.com/flash/widgets/profile/TwitterWidget.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<param name="FlashVars" value="userID=25953215&styleURL=http://static.twitter.com/flash/widgets/profile/revo.xml" />
<embed src="http://static.twitter.com/flash/widgets/profile/TwitterWidget.swf" quality="high" bgcolor="#000000" width="290" height="350" name="TwitterWidget" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="userID=25953215&styleURL=http://static.twitter.com/flash/widgets/profile/revo.xml"/>
</object>
</div>
<!-- end #sidebar1 --></div>
<div id="sidebar2">
<br /><br />
<div align="center">
<img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 src="http://counters.gigya.com/wildfire/IMP/CXNID=2000002.11NXC/bT*xJmx*PTEyNDAyOTMwNjU*NjImcHQ9MTI*MDI5MzA2ODQwNS ZwPTI3MDgxJmQ9YmxvZ19wbGF5ZXJfZmlyc3RfZ2VuJmc9MSZ* PSZvZj*w.gif" />
<embed type="application/x-shockwave-flash" src="http://cache.reverbnation.com/widgets/swf/28/blog_player.swf?emailPlaylist=artist_426727&backgroundcolor=017DDE&font_color=000000&posted_by=artist_426727&shuffle=true&autoPlay=true" height="300" width="180"/><br/><a href="http://www.reverbnation.com/c./a4/28/426727/Artist/426727/Artist/link"><img alt="The%20Autumn%20Window" border="0" height="12" src="http://cache.reverbnation.com/widgets/content/28/footer.png" width="180" /></a><br/><img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 src="http://www.reverbnation.com/widgets/trk/28/artist_426727/artist_426727/t.gif"/><a href="http://www.quantcast.com/p-05---xoNhTXVc" target="_blank"><img src="http://pixel.quantserve.com/pixel/p-05---xoNhTXVc.gif" style="display: none" border="0" height="1" width="1" alt="Quantcast"/></a>
</div>
<!-- end #sidebar2 --></div>
<div id="mainContent">
<div id="header">
<div align="center">
<img src="images/topname.png" width="95%" />
</div>
</div>
</div>
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
<!-- end #container --></div>
</body>
</html>
CSS:

@charset "utf-8";
/* CSS Document */
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #FFF;
margin: 0px; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0px;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
border:none;
width: 100%;
height: 100%;
}
.thrColLiq #container {
width: 100%; /* this will create a container 100% of the browser width */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 0px;
text-align: left; /* this overrides the text-align: center on the body element. */
}
/* Tips for sidebars:
1. Since we are working in percentages, it's best not to use side padding on the sidebars. It will be added to the width for standards compliant browsers creating an unknown actual width.
2. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".thrColLiq #sidebar1 p" rule.
3. Since Explorer calculates widths after the parent element is rendered, you may occasionally run into unexplained bugs with percentage-based columns. If you need more predictable results, you may choose to change to pixel sized columns.
*/
.thrColLiq #sidebar1 {
float: left; /* this element must precede in the source order any element you would like it be positioned next to */
width: 380px; /* since this element is floated, a width must be given */
background-image:url(images/Page-Left.jpg); /* the background color will be displayed for the length of the content in the column, but no further */
padding: 0px 0; /* top and bottom padding create visual space within this div */
border:0px;
height: 1200px;
}
.thrColLiq #sidebar2 {
float: right; /* this element must precede in the source order any element you would like it be positioned next to */
width: 380px; /* since this element is floated, a width must be given */
background-image:url(images/Page-Right.jpg); /* the background color will be displayed for the length of the content in the column, but no further */
padding: 0px 0; /* top and bottom padding create visual space within this div */
border:0px;
height: 1200px;
}
.thrColLiq #sidebar1 p, .thrColLiq #sidebar1 h3, .thrColLiq #sidebar2 p, .thrColLiq #sidebar2 h3 {
margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 10px;
}
/* Tips for mainContent:
1. the space between the mainContent and sidebars is created with the left and right margins on the mainContent div.
2. to avoid float drop at a supported minimum 800 x 600 resolution, elements within the mainContent div should be 300px or smaller (this includes images).
3. in the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs.
*/
.thrColLiq #mainContent {
margin: 0 24% 0 23.5%; /* the right and left margins on this div element creates the two outer columns on the sides of the page. No matter how much content the sidebar divs contain, the column space will remain. You can remove this margin if you want the #mainContent div's text to fill the sidebar spaces when the content in each sidebar ends. */
}
/* Miscellaneous classes for reuse */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain its child floats */
clear: both;
height: 0;
font-size: 1px;
line-height: 0px;
}
-->
</style><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.thrColLiq #sidebar2, .thrColLiq #sidebar1 { padding-top: 30px; }
.thrColLiq #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->

The Autumn Window
04-21-2009, 09:48 AM
Also, as a side note, in Safari 4 and Opera 9 the top PNG "topname.png" doesn't show up but in FF3 and IE7 it does. Any ideas on how to correct that?

domedia
04-21-2009, 09:54 PM
The structure is broken, run it through a validator and see the errors. Did you check it in FF as well? It looks kinda weird..

The Autumn Window
04-21-2009, 11:10 PM
what do you mean "the structure is broken"?

and FF looks fine aside from the space.

coloeagle
04-22-2009, 04:12 AM
You have your container set to be 100% of the browser width. Your have one sidebar floating left and one floating right.

This setup will place the sidebars on the right and left sides of the browser. Try floating both sidebars left and set your container width to the appropriate width so that the sidebars fill the container.

The Autumn Window
04-22-2009, 04:24 AM
but I want a sidebar on either side of the mainContent and I want the three columns (2 sidebars and mainContent) to take up a total of 100% of the screen's width.

coloeagle
04-22-2009, 04:00 PM
Set/adjust your left and right margins with pixels and not percentages, matching your left and right column widths. This will let the main content flex to fill the area between your columns depending on a visitors browser setting.

The Autumn Window
04-22-2009, 04:34 PM
no luck. I'm speaking of the space on the outside of the child DIVs

domedia
04-22-2009, 05:08 PM
what do you mean "the structure is broken"? The code is broke, run it through a validator and you'll see the errors.

The Autumn Window
04-22-2009, 10:04 PM
there's a ton of errors, but none of them make actual sense to me.

p.s. I figured out the space issue. i had to set the html's margins to 0px.

not sure why, but it worked.