Skip to content

Instantly share code, notes, and snippets.

@lulalala
Created July 6, 2011 03:33
Show Gist options
  • Save lulalala/1066502 to your computer and use it in GitHub Desktop.
Save lulalala/1066502 to your computer and use it in GitHub Desktop.
Simplication of The Holy Grail of Layouts using Border-box model
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>The Holy Grail of Layouts: Example #1: A List Apart (Using Border-box model)</title>
<style type="text/css">
body {
min-width: 550px; /* prevent narrow window from breaking layout */
}
div {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
#container {
padding-left: 200px; /* LC width */
padding-right: 150px; /* RC width */
overflow:hidden; /* Equal height */
}
#container .column {
float:left;
position: relative;
padding: 0 10px;
padding-bottom: 20000px; /* Equal height */
margin-bottom: -20000px; /* Equal height */
}
#center.column {
width:100%;
padding: 10px 20px;
padding-bottom: 20000px; /* Equal height */
}
#left {
width: 200px;
margin-left:-100%;
right:200px;
}
#right {
width:150px;
margin-right:-150px;
}
#header {
padding: 10px;
}
#footer {
padding: 10px;
clear:both;
position: relative;
}
/* ie6 */
* html #left {
left: 150px; /* RC width */
}
</style>
</head>
<body>
<div id="header" style="background:LemonChiffon;"><h1>This is the header.</h1></div>
<div id="container">
<div id="center" class="column" style="background:NavajoWhite;">
<h1>This is the main content.</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla.</p>
</div>
<div id="left" class="column" style="background:Cornsilk;">
<h2>This is the left sidebar.</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla.</p>
</div>
<div id="right" class="column" style="background:BurlyWood;">
<h2>This is the right sidebar.</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla.</p>
</div>
</div>
<div id="footer" style="background:DarkKhaki;">This is the footer.</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment