The following html and css code is an example of a 3 column liquid layout used on the front page of http://slashdot.org. What's interesting is that the left and right column do not change their widths, it's only the article content which changes.
1
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
7 <title>Aenean: ullamcorper elementum, dui quam porttitor neque</title>
8 <link rel="stylesheet" type="text/css" media="screen" href="core-tidied.css" />
9
10 </head>
11 <body>
12 <div id="frame">
13 <div id="topnav">
14 <div id="logo">
15 <h1>
16 <a href="//aenean.org">Aenean</a>
17 </h1>
18 </div>
19 </div>
20 <div id="slogan">
21 <h2>
22 ullamcorper elementum, dui quam porttitor neque
23 </h2>
24 </div>
25 <div id="wrapper">
26 <div id="links">
27 <div class="block" id="links-sections">
28 <div class="title" id="links-sections-title">
29 <h4>
30 hendrerit
31 </h4>
32 </div>
33 <div class="content" id="links-sections-content">
34 <ul>
35 <li>suscipit</li>
36 </ul>
37 </div>
38 </div>
39 </div>
40 <div id="contents">
41 <div id="slashboxes">
42 <div class="block">
43 <div class="title" id="index_qlinks-title">
44 <h4>
45 Vestibulum
46 </h4>
47 </div>
48 <div class="content" id="index_qlinks-content">
49 <p>egestas quam </p>
50 </div>
51 </div>
52 </div>
53 <div id="articles">
54 <div class="article" id="art1">
55 <p>
56 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec tincidunt porttitor felis. Sed a tellus in lacus adipiscing tincidunt. Ut sollicitudin auctor dolor. Maecenas orci. Fusce porttitor odio eget erat. Aliquam erat volutpat. Fusce mollis, orci eget ullamcorper elementum, dui quam porttitor neque, euismod pulvinar risus turpis nec neque. Maecenas dolor risus, vestibulum in, congue a, pulvinar id, leo. Vestibulum porttitor hendrerit mauris. Morbi fringilla lectus quis orci. Vivamus laoreet massa scelerisque felis.
57 </p>
58
59 <p>
60 Aenean nunc neque, euismod porta, tempor ut, eleifend at, massa. Nam tempor urna at ligula. Etiam auctor dui tempus odio egestas sagittis. Donec metus pede, tempor nec, tincidunt sit amet, consectetuer eget, massa. Nam dolor arcu, ornare et, imperdiet vel, euismod ut, nibh. Quisque ut erat. Maecenas ante urna, suscipit eget, dictum non, porttitor at, magna. Duis accumsan. Suspendisse luctus vehicula pede. Mauris a nisl. Cras leo.
61 </p>
62 </div>
63 </div>
64 </div>
65 </div>
66 <div id="footer">
67 Ut sollicitudin auctor dolor. Maecenas orci.
68 </div>
69 </div>
70
71 </body>
72 </html>
1
2
3 /* file: core-tidied.css */
4 body {
5 min-width: 680px;
6 color:
7 background:
8 }
9
10
11 background-color:
12 }
13
14
15 background:
16 position: relative;
17 height: 55px;
18 margin: 5px 1.25em 0 1.25em;
19 }
20
21
22 width: 415px;
23 height: 100%;
24 }
25 #topnav #logo h1 {
26 display: block;
27 height: 100%;
28 width: 100%;
29 }
30
31 display: block;
32 width: 100%;
33 height: 100%;
34 outline: none;
35 text-indent: -5000px;
36 text-decoration: none;
37 background: url(//images.slashdot.org/logo.png) no-repeat left top;
38 }
39
40
41
42 /* Wrapper */
43
44 overflow: hidden;
45 background-color:
46 }
47
48
49
50 /* User section menu */
51 /* Contents */
52
53 width: auto;
54 margin-left: 10.5em;
55 }
56
57 /* General Body */
58
59 /* Blocks */
60 div.block div.title { background:
61 div.block div.title h4 {
62 color:
63 }
64
65
66 /* Links (left sidebar) */
67 div
68 float: left;
69 width: 9.25em;
70 background:
71 }
72 div
73
74 /* Slashboxes (right sidebar) */
75 div
76 float: right;
77 width: 17.25em;
78 }
79
80 /* Footer */
81 div
82 background:
83 clear: both;
84 }
85
86
The secret to positioning the columns, is to use left and right margins to push the element (column being adjusted), away from it's siblings. In the above example the contents (outer box) is pushed away from the left (#contents { margin-left: 10.5em;}), and the articles (inner box) within the contents is pushed from the right (#wrapper #articles { margin-right: 18.5em; }).