Style Sheets
  Home arrow Style Sheets arrow Page 4 - Creating Hybrid Web Page Layouts with Nega...
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 Hybrid Web Page Layouts with Negative Margins
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-09

    Table of Contents:
  • Creating Hybrid Web Page Layouts with Negative Margins
  • Hybrid layout foundations:
  • Creating a hybrid web page layout with CSS negative margins
  • Completing a hybrid 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


    Creating Hybrid Web Page Layouts with Negative Margins - Completing a hybrid web page layout


    (Page 4 of 4 )

    As I stated in the section that you just read, below I listed the complete source code required to build a hybrid web page layout using CSS negative margins. In addition, I styled the header and footer section of the web page in question, but naturally you can modify this and use your own CSS styles.

    Having clarified that point, please pay close attention to the following (X)HTML file, which is responsible for constructing the hybrid design that I mentioned earlier:


    <!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 three-column web page layout using negative margins with fixed width</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #eee;

    }

    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 navigation bar */

    #navbar{

    float: left;

    width: 200px;

    background: #ccc;

    }

    /* wraps up the whole page */

    #mainwrapper{

    width: 800px;

    margin-left: auto;

    margin-right: auto;

    }

    /* wraps up the main column */

    #colwrapper{

    float: left;

    width: 100%;

    margin-left: -200px;

    margin-right: -200px;

    }

    /* style main column */

    #maincol{

    margin-right: 200px;

    margin-left: 200px;

    background: #fff;

    }

    /* style side column */

    #sidecol{

    float: right;

    width: 200px;

    background: #ccc;

    }

    /* style footer section */

    #footer{

    clear: both;

    background: #ffc;

    }

    </style>

    </head>

    <body>

    <div id="mainwrapper">

    <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="navbar">

    <h1>Nav Bar</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="colwrapper">

    <div id="maincol">

    <h1>Main Column 1</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>Right 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>

    </div>

    </body>

    </html>


    That’s it. Now you have at your disposal all of the source code required to build a hybrid design that uses negative margins to accommodate the respective containing DIVs. Also, if you want to see how the previous web document looks, here’s an screen capture that shows pretty clearly its visual appearance:



    Final thoughts

    Unfortunately, we’ve come to the end of the series. But overall the experience has been educational, since you learned how to take advantage of CSS negative margins to build different types of web page layouts. Certainly, negative margins aren’t the only approach that you can use to create DIV-based web page designs, but admittedly it is one of the most consistent and easiest to learn.

    See you in the next web development tutorial!


    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.

       · This final installment of the series shows how to create an hybrid web page layout...
       · First of all, thanks for the knowledge you have shared in this site.But your...
       · Thanks for the kind words on my CSS article. Yes, negative margins can be a bit...
     

    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 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek