Home arrow Style Sheets arrow Page 3 - Matching Web Page Columns with CSS
STYLE SHEETS

Matching Web Page Columns with CSS


For a long time, conscientious web designers have known that building web page layouts where the heights of the main columns are neatly matched is required to achieve a truly professional look and feel for a web site. This three-part article series will show you a good approach for creating this result.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 5
July 18, 2007
TABLE OF CONTENTS:
  1. · Matching Web Page Columns with CSS
  2. · Building a DIV-based web page layout with unleveled columns
  3. · Matching the heights of web page columns
  4. · Achieving a fully-balanced three-column web page layout

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Matching Web Page Columns with CSS - Matching the heights of web page columns
(Page 3 of 4 )

As I explained in the section that you just read, evening the columns of a specific web document is actually a process that can be performed with minor hassles, and certainly without the need to use the assistance of JavaScript. In this case, I'm going to use only a CSS-based approach to match the different heights of the corresponding web page columns.

So, at this moment maybe you're wondering: how much does it take to fix the columns in question? Well, to be frank, the answer to that question is...only a few additional CSS styles. Yes, to keep the web document columns completely balanced, I'm going to include a simple wrapping DIV, which will be tasked obviously with containing each of the unleveled columns, in this way matching their respective heights.

That being said, the CSS styles required to create the previously mentioned wrapping DIV can be coded as follows:

#mainwrapper{
   clear: both;
   height: 100%;
   overflow: hidden;
   background: #eee;
}

#mainwrapper .leftcol{
   position: relative;
   float: left;
}

#mainwrapper .rightcol{
   position: relative;g
   float: right;
}

Basically, the function of the above basic CSS styles is simply to declare a new "mainwrapper" selector, which when used in conjunction with the respective "left" and "right" classes previously created, will make any DIV element contained in the wrapper in question float to the left or the right of a specific web page.

As you can see, the addition of a simple wrapping DIV to the existing columns of a given web document is a basic -- yet efficient -- technique that really balances their heights, which implies that the issue can be quickly fixed by using a pure CSS-based methodology. In this case, I adapted this technique from a existing method created by Matthew Levine, which you can see in detail here

Okay, at this stage hopefully you learned how the previously-defined wrapping DIV can be capable of keeping the columns of a web document entirely leveled. However, I must admit that you won't see the result of applying this technique until I show you how the previous CSS styles and the corresponding markup are linked with each other.

Thus, taking into account this important requisite, in the next section I'm going to list the complete signature of the sample (X)HTML that you saw earlier, so you can see how a concrete web document can display its respective columns entirely balanced.

To see how this will be done, jump ahead and read the next few lines. I'll be there, waiting for you.


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials