Now that we have prepared our text and put styling in an external file, we only need to structure our content on a webpage (right now the content is in a single column).
Here is what we have for now:
<div class="logo"> Company name </div> <ul class="topnav"> <li>Home</li> <li>Services</li> <li>About</li> </ul> <div class="content"> <h1>Page heading</h1> <p>Some paragraph text here</p> <p>..more content..</p> </div> <ul class="leftnav"> <li>Service 1</li> <li>Service 2</li> <li>Service 3</li> </ul> <div class="footer"> Copyright © 2006 </div>
So, let's finish our work.
Initially, we had a site on tables. It had a certain layout, where page content was positioned in different part of the browser window. As you are redesigning a site, most likely, the visual layout may be the same with your old site. For the sake of simplicity, let's pretend that our example consists of a heading, a top navigation, the left navigation, the main content area and a footer.
In this example, we only need to position the left navigation to the left of the screen, with the content area on the right of the left navigation, because the top navigation and the footer are not included in the wrapping <div class="container">.To do this, we'll use floats. Here is what we add to the CSS file:
body {margin:0;padding:0;}
.topnav li {float:left;width:15%;list-style:none;}
.topnav {margin:0 0 0 10em;}
.container {padding-left:10em; min-width:11em;}
.content, .leftnav {position:relative; float:left;}
.content {width:100%;}
.leftnav {width:10em;margin-left:-100%;right:10em;}
.leftnav li {list-style-type:none;}
.footer:before, .topnav:after {clear:both;content:'';
visibility:hidden;display:block;}
.footer {text-align:center;}
/*IE hacks*/
.content {display:inline;}
Read the description of the CSS code above, below:
float:left', remove list styling and set a fixed width. To move the nav to the right, we set a left margin, equal to the width of the left column.After you have created a bare skeleton for your site (see example), you can style it up by adding borders, adding colors to links (active, hover, visited states), etc.
If you want to try another technique for creating liquid layouts, you can try a "One True Layout" from PositionIsEverything.
Note: the demonstrated model was insighted by "The One True Layout". The example works (was tested, that is) in IE 6.0, Firefox 1.5 and Opera 8.51. Supposedly, it works in all other browsers (it is not confirmed, though). It has only one IE hack, aimed to remove the box model IE bug and another bug (the author of this tutorial has forgotten about), so it should be deemed as relatively 'hack-free' example.
Learn more:
Though it is important for people to find the information quickly, they also enjoy finding it easily.
Check out the recently added articles: