Style Sheets
  Home arrow Style Sheets arrow Page 2 - Creating Web Page Layouts with Negative Ma...
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 Web Page Layouts with Negative Margins
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 3
    2008-08-19

    Table of Contents:
  • Creating Web Page Layouts with Negative Margins
  • Building a quick and dirty two-column web page layout
  • Using negative margins to position the main DIVs of a web document
  • Defining an additional wrapping DIV

  • 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 Web Page Layouts with Negative Margins - Building a quick and dirty two-column web page layout


    (Page 2 of 4 )

    A good point to start demonstrating how negative margins can be used to create consistent web page layouts consists of building a rudimentary web document, which will be comprised of two primary columns, where the first one will be placed on the left and the second one, obviously, will be positioned on the right of the document in question.

    The structural markup of the mentioned web document will look 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</title>

    </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="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 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 can see, the structure of the previous web page is actually very simple to grasp. In simple terms, it's made up of the typical header and footer sections, while the middle section contains two primary columns. So far, nothing weird, right?

    Now, having defined the markup, and some trivial contents corresponding to the above web document, it's time to apply some CSS styles to it and see how the main DIVs can be properly positioned to the left and right sides of the document in question.

    Indeed, things are getting interesting now! So, in the following section I'll be defining the aforementioned CSS styles that will be tasked with constructing a basic two-column web page layout by specifying a few negative margins.

    To see how this will be done, please click on the link below and keep reading.

    More Style Sheets Articles
    More By Alejandro Gervasio


       · Negative margins are a popular CSS technique used for building div-based web page...
       · By changing the order <div id="sidecol">...</div><!-- <div...
       · Thanks for commenting on my article. Yes, it’s possible to build variations of the...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







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