Style Sheets
  Home arrow Style Sheets arrow Page 4 - Matching Web Page Columns with CSS
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Matching Web Page Columns with CSS
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-07-18

    Table of Contents:
  • Matching Web Page Columns with CSS
  • Building a DIV-based web page layout with unleveled columns
  • Matching the heights of web page columns
  • Achieving a fully-balanced three-column web page layout

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Matching Web Page Columns with CSS - Achieving a fully-balanced three-column web page layout


    (Page 4 of 4 )

    According to the concepts deployed in the prior section, in this case it's necessary to demonstrate how the wrapping DIV created previously is capable of balancing the heights of the three columns created for the sample web page that you saw before.

    Therefore, and bearing this crucial objective in mind, now take a look at the modified version of the (X)HTML file shown in the beginning, this time including the pertinent wrapping DIV. Here's how this file looks:  

    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-
    8859-1" />
    <style type="text/css">
    body{
       padding: 0;
       margin: 0;
       background: #fff;
    }

    h2{
       margin: 0;
       font: bold 18px Arial, Helvetica, sans-serif;
       color: #000;      
    }

    p{
       font: normal 12px Arial, Helvetica, sans-serif;
       color: #000;      
    }

    #header{
       padding: 2%;
       background: #ffc;
    }

    #navbar{
       padding: 1% 2% 1% 2%;
       background: #fc0;
    }

    #navbar ul{
       list-style: none;
    }

    #navbar li{
       display: inline;
       padding-right: 4%;
    }

    #navbar a:link,#navbar a:visited{
       font: normal 12px Arial, Helvetica, sans-serif;
       color: #039;
       text-decoration: none;
    }

    #navbar a:hover{
       text-decoration: underline;
    }

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

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

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

    #leftbar{
       width: 16%;
       padding: 2%;
    }

    #centerbar{
       float: left;
       width: 55%;
       padding: 2%;
       background: #fff;
    }          

    #rightbar{
       width: 16%;
       padding: 2%;
    }

    #footer{
       clear: both;
       padding: 2%;
       background: #ffc;
    }
    </style>
    <title>Example of evened columns - Liquid design</title>
    </head>
    <body>
     
    <div id="header">
       
    <h2>This is the header section of the web page</h2>
       
    <p>Contents for header section go here. Contents for header
    section go here. Contents for header section go here. Contents
    for header section go here.</p>
     
    </div>
     
    <div id="navbar">
       
    <h2>This is the navigation bar of the web page</h2>
        
    <ul>
         
    <li><a href="#">Link 1</a></li>
         
    <li><a href="#">Link 2</a></li>
         
    <li><a href="#">Link 3</a></li>
         
    <li><a href="#">Link 4</a></li>
         
    <li><a href="#">Link 5</a></li>
         
    <li><a href="#">Link 6</a></li>
       
    </ul>
     
    </div>
     
    <div id="mainwrapper">
       
    <div id="leftbar" class="leftcol">
         
    <h2>This is the left column of the web page</h2>
         
    <p>Contents for left column go here. Contents for left
    column go here. Contents for left column go here. Contents for
    left column go here. Contents for left column go here. Contents
    for left column go here. Contents for left column go here.
    Contents for left column go here. Contents for left column go
    here. Contents for left column go here.</p>
       
    </div>
       
    <div id="centerbar" class="leftcol">
         
    <h2>This is the center column of the web page</h2>
          
    <p>Contents for center column go here. Contents for center
    column go here. Contents for center column go here. Contents for
    center column go here. Contents for center column go here.
    Contents for center column go here. Contents for center column go
    here. Contents for center column go here. Contents for center
    column go here. Contents for center column go here.</p>
         
    <p>Contents for center column go here. Contents for center
    column go here. Contents for center column go here. Contents for
    center column go here. Contents for center column go here.
    Contents for center column go here. Contents for center column go
    here. Contents for center column go here. Contents for center
    column go here. Contents for center column go here.</p>
         
    <p>Contents for center column go here. Contents for center
    column go here. Contents for center column go here. Contents for
    center column go here. Contents for center column go here.
    Contents for center column go here. Contents for center column go
    here. Contents for center column go here. Contents for center
    column go here. Contents for center column go here.</p>
         
    <p>Contents for center column go here. Contents for center
    column go here. Contents for center column go here. Contents for
    center column go here. Contents for center column go here.
    Contents for center column go here. Contents for center column go
    here. Contents for center column go here. Contents for center
    column go here. Contents for center column go here.</p>
        
    </div>
       
    <div id="rightbar" class="rightcol">
         
    <h2>This is the right column of the web page</h2>
         
    <p>Contents for right column go here. Contents for right
    column go here. Contents for right column go here. Contents for
    right column go here. Contents for right column go here.</p>
       
    </div>
     
    </div>
     
    <div id="footer">
       
    <h2>This is the footer section of the web page</h2>
       
    <p>Contents for footer section go here. Contents for footer
    section go here. Contents for footer section go here. Contents
    for footer section go here. Contents for footer section go
    here.</p>
     
    </div>
    </body>
    </html>

    Wasn't that easy to achieve? I bet it was! As you can see the above (X)HTML file displays a liquid web page whose main columns look completely balanced. Besides, in case the previous code sample isn't enough for you, this neat effect can be seen with more accuracy in the following screen shot:

    As demonstrated by the above image, now the sample web document displays its respective columns fully balanced on the browser. Logically, this effect has been achieved by assigning one background color to the wrapping DIV defined previously, and a different one to the centered column, but this technique can be quite useful when working with either liquid or fixed layouts.

    As with many other topics related to web development, the best way for you to learn the previous approach is by creating your own test examples.

    Final thoughts

    In this first part of the series, you learned how to implement a basic CSS-based solution, aimed at keeping the respective columns of a given web document entirely leveled. Nevertheless, this method has been used along with a liquid web page layout, thus in the next part I'm going to teach you how to utilize it with a fixed design.

    Want to see how this will be done? Don't miss the next article! 


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · While the topic has been covered already by many web designers, this article shows a...
       · I am just a beginner so I am looking at all the tutorial that I can find. I found...
       · Hi Susie,Thank you for the kind words on my CSS article. It's good to know that...
       · Ok, but what if you put only one paragraph in "centerbar" container and set its...
       · Thanks for the comments on my article. It’s very easy to solve the issue you...
       · As a beginner I appreciate the effort you put into making this information...
       · Hi Ron,Thank you for the comments on my CSS article, and it’s good to know it’s...
       · Does this work with a floating div design as well? See, I made a basic floating...
       · Thanks for this wonderful article. It works like a charm.I was wondering though,...
       · Thanks for the comments on my article. Wit reference to your question, yes it’s...
       · Hi Brett,Thanks for the kind comments on my article. Regarding your question,...
     

    STYLE SHEETS ARTICLES

    - Creating Three-Column Web Page Layous with N...
    - Swapping Column Positions in Web Page Layout...
    - Creating Web Page Layouts with Negative Marg...
    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification
    - CSS: Dimensions
    - CSS: Margins and Padding
    - CSS: Crossing the Border
    - CSS: Text, Fonts, and Tables







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway