A basic technique for swapping two columns in a layout.
In the following example, a content area follows a sidebar in document order:
<div id="example1">
<div class="sidebar"></div>
<div class="content"></div>
</div>
.sidebar, .content { height: 60px; float: left; }
.sidebar { width: 100px; background-color: #9DB029; }
.content { width: 300px; background-color: #3465A4; }
Sometimes, there exists a need to swap the two around, without modifying their order in the original document. To achieve this, we can use negative margins:
#example2 .sidebar { margin-left: 300px; } #example2 .content { margin-left: -400px; }
Just to clarify those measurements: