Style Sheets
  Home arrow Style Sheets arrow Page 3 - Swapping Column Positions in Web Page Layo...
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

Swapping Column Positions in Web Page Layouts with Negative Margins
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2008-08-26

    Table of Contents:
  • Swapping Column Positions in Web Page Layouts with Negative Margins
  • Review: using negative margins to build a two-column liquid design
  • Swapping the position of web page columns
  • The complete source code for the previous two-column liquid 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


    Swapping Column Positions in Web Page Layouts with Negative Margins - Swapping the position of web page columns


    (Page 3 of 4 )

    As I stated in the section that you just read, a two-column web page layout like the one created previously can be easily modified to swap the positions of its respective columns. In other words, the consequence in doing this would be that the corresponding side bar now would be placed on the left of the web document, and the main column obviously would be floated to the right.

    Of course, to construct this brand new layout I’m going to use the handy negative margin approach, so the CSS styles corresponding to this example now look like this:

    /* 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;

    }


    That was pretty simple to understand, wasn’t it? As you can see, since my intention was simply to revert the positions of the main and side columns within the pertinent web document, I specified a negative value of –300 px for the wrapper of the main column, which also has been floated to the right. On the other hand, the side bar has been floated to the left, swapping the positions between these containing elements.

    In addition, the rest of the CSS styles listed above are responsible for styling the respective header and footer section of the web page, so I won’t bore you with irrelevant explanations about how they work.

    Well, at this moment, you have learned how to use the functionality of CSS negative margins to invert the respective positions of the two primary columns within a sample web page. As you probably realized, this process is a no-brainer and can be tackled with minor problems.

    However, undoubtedly the missing piece of this schema is the structural markup that’s tied to the CSS styles coded earlier. Taking this into account, therefore, in the section to come I’m going to show you the full source code of this two-column web page layout, whose respective main columns have been swapped.

    Don’t waste more time; read the next few lines. I’ll be there, waiting for you.

    More Style Sheets Articles
    More By Alejandro Gervasio


       · In the introductory part of this series, negative CSS margins were employed to...
     

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