View Full Version : main content div to match container

09-26-2009, 05:57 PM
I would like to tighten up this page so things can appear fairly uniform in different browser widths. The designer link and share this at bottom right take on the width of the footer, which is the same as what the container uses (80%).
I would like that to stay just under the bottom right corner of the main image at all times.



@charset "UTF-8";
body {
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
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: #fff;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
background-color: #000000;
.twoColHybLtHdr #container {
width: 80%; /* this will create a container 80% of the browser width */
background: #000000;
margin: 0 35px 0 35px; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
.twoColHybLtHdr #header {
background: #000000;
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
.twoColHybLtHdr #header h1 {
margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */

/* Tips for sidebar1:
1. Since we are working in relative units, it's best not to use padding on the sidebar. It will be added to the overall width for standards compliant browsers creating an unknown actual width.
2. Since em units are used for the sidebar value, be aware that its width will vary with different default text sizes.
3. 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 ".twoColHybLtHdr #sidebar1 p" rule.
.twoColHybLtHdr #sidebar1 {
float: left;
width: 200px; /* since this element is floated, a width must be given */
background: #000000; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 10px 0; /* top and bottom padding create visual space within this div */
margin-top: 50px;
height: 650px;
#form {
height: 400px;
width: 200px;
margin-top: 90px;
.twoColHybLtHdr #sidebar1 h3, .twoColHybLtHdr #sidebar1 p {
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;
text-align: left;

/* Tips for mainContent:
1. The space between the mainContent and sidebar1 is created with the left margin on the mainContent div. No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
2. Be aware it is possible to cause float drop (the dropping of the non-floated mainContent area below the sidebar) if an element wider than it can contain is placed within the mainContent div. WIth a hybrid layout (percentage-based overall width with em-based sidebar), it may not be possible to calculate the exact width available. If the user's text size is larger than average, you will have a wider sidebar div and thus, less room in the mainContent div. You should be aware of this limitation - especially if the client is adding content with Contribute.
3. In the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This may help avoid several IE-specific bugs.
.twoColHybLtHdr #mainContent {
margin: 0 20em 0 13.5em; /* the right margin can be given in percentages or pixels. It creates the space down the right side of the page. */
.twoColHybLtHdr #footer {
padding: 0 0px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
text-align: right;
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
color: #999;
margin-top: 30px;
a {
color: #999;
.twoColHybLtHdr #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */

/* 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 */
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 a float */
font-size: 1px;
line-height: 0px;
.twoColHybLtHdr #container #footer p {
font-family: Verdana, Geneva, sans-serif;
#nav {
float: none;
width: 200px;
padding-top: 60px;

09-26-2009, 09:49 PM
It seems rather pointless to set #container to 80%. Why not just make it the width needed to accomodate your large image? Then you could do away with the width of #footer and just let it fill the width of #container.

09-27-2009, 05:54 AM
agreed....but if I say change it to 771px everything goes everywhere. I believe because the main content is controlled only by margine, would that be right?