Style Sheets
  Home arrow Style Sheets arrow Page 2 - Creating Three-Column Web Page Layous with...
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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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

Creating Three-Column Web Page Layous with Negative Margins
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-09-03

    Table of Contents:
  • Creating Three-Column Web Page Layous with Negative Margins
  • A first step: a basic two-column web page layout
  • Building three-column web page layouts
  • Listing the full source code of the three-column web page design

  • 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


    Creating Three-Column Web Page Layous with Negative Margins - A first step: a basic two-column web page layout


    (Page 2 of 4 )

    As you know, a hands-on approach is the best way to explain many topics of professional web development, and negative margins definitely aren't an exception. Therefore, before I teach you how to use them to build a few three-column web page layouts, first let me give you a practical example that shows how to build one that's only made up of two columns.

    The example in question was developed in the previous tutorial of the series and it looked like this:

    <!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" />

    <title>Example on two-column web page layout using negative margins</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    h1{

    font: bold 12pt Arial, Helvetica, sans-serif;

    color: #000;

    margin: 0;

    }

    p{

    font: normal 10pt Arial, Helvetica, sans-serif;

    color: #000;

    margin: 0;

    }

    /* style header section */

    #header{

    background: #ffc;

    }

    /* style side column */

    #sidecol{

    float: left;

    width: 300px;

    background: #eee;

    }

    /* wraps up the main column */

    #wrapper{

    width: 100%;

    float: right;

    margin-left: -300px;

    }

    /* style main column */

    #maincol{

    margin-left: 300px;

    }

    /* style footer section */

    #footer{

    clear: both;

    background: #ffc;

    }

    </style>

    </head>

    <body>

    <div id="header">

    <h1>Header Section</h1>

    <p>This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section. This is the content of the header section.</p></div>

    <div id="wrapper">

    <div id="maincol">

    <h1>Main Column</h1>

    <p>This is the content of the main column. This is the content of the main column. This is the content of the main column. This is the content of the main column. This is the content of the main column. This is the content of the main column. This is the content of the main column. This is the content of the main column. This is the content of the main column. This is the content of the main column.</p></div>

    </div>

    <div id="sidecol">

    <h1>Side Column</h1>

    <p>This is the content of the side column. This is the content of the side column. This is the content of the side column. This is the content of the side column. This is the content of the side column. This is the content of the side column. This is the content of the side column. This is the content of the side column. This is the content of the side column. This is the content of the side column.</p></div>

    <div id="footer">

    <h1>Footer Section</h1>

    <p>This is the content of the footer section. This is the content of the footer section. This is the content of the footer section. This is the content of the footer section. This is the content of the footer section. This is the content of the footer section. This is the content of the footer section. This is the content of the footer section. This is the content of the footer section. This is the content of the footer section.</p></div>

    </body>

    </html>

    As you'll surely remember, the previous (X)HTML file is responsible for constructing a raw web page layout. This layout is comprised of the typical header and footer sections, as well as two primary columns, identified as "sidebar" and "maincol" respectively.

    Of course, as you can see, the most relevant detail to stress here is that the main column has been positioned within the pertinent web document via an additional wrapper, which uses a negative value for its left margin, to pull it away from the side bar. This creates the basic web page layout that you saw earlier. Not too difficult to grasp, right?

    Now that I dedicated a few moments to refreshing the key concepts surrounding the creation of two-column web page layouts by using CSS negative margins, I'm going to implement the same approach with the purpose of building a three-column web document design.

    Looks pretty useful, right? Thus, to learn the details inherent to this interesting process, please click on the link that appears below and keep reading.

    More Style Sheets Articles
    More By Alejandro Gervasio


       · This third installment of the series demonstrates how to use negative CSS margins...
       · Hi Alejandro,I have been playing with your 3-col CSS layout (many thanks for...
       · Thanks Martin for the comments on my CSS article. First off, negative CSS margins...
       · Hi Alejandro,Thanks for taking the time to reply. The frames issue is because at...
       · Hey Martin,If you’re getting more problems with your linked lists, try...
     

    STYLE SHEETS ARTICLES

    - Building Rounded Corners with CSS3`s -webkit...
    - Using the Custom -moz-border-radius Property...
    - Using CSS3`s Border-Radius Property to Build...
    - Adding Semantic Meaning to Styled Code Block...
    - Styling Code blocks with CSS: Using pre HTML...
    - Building Rounded Corners with CSS3
    - Finishing a Casual Navigation Bar with CSS S...
    - Defining a Navigation Bar`s Hover State with...
    - Styling a Blog`s Links Bar with CSS Sprites
    - Creating an Artistic Blog Header with CSS Sp...
    - Defining the Active State of Menu Sections f...
    - Styling the Hover State of a CSS Sprite-Base...
    - Building CSS Sprite-Based Navigation Bars
    - Creating Framed Pictures with CSS
    - Using a CSS Shading Effect to Decorate Images







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek