3 Column CSS Layout with Header and Footer

I am not a designer. But that should not stop me from trying when I come across a designing requirement. I helped a colleague of mine with a designing requirement where he needed to design a 3 Column Layout using CSS that had a header and footer. One of the main requirements was that the layout should automatically get adjusted (flow) to the contents. We took tips from loads of articles on the same topic and here’s what we came up with

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>3 Column CSS Layout with Header and Footer</title>
<
style type='text/css'>
.header{
position: relative;
float: left;
width: 100%;
background-color: #356aa0
}
.container{
position: relative;
float: left;
width: 100%;
background-color: #cccccc
}
.left{
position: relative;
float: left;
width: 20%;
background-color: #a2b5cd
}
.center{
position: relative;
float: left;
left: 1%;
right:1%;
width: 58%;
background-color: #a2b5cd
}
.right{
position: relative;
float: right;
width: 20%;
background-color: #a2b5cd
}
.footer{
position: relative;
float: left;
width: 100%;
background-color: #356aa0
}
body {
padding: 0px;
margin: 2%;
background-color: #e7e7de
}
</style>
</
head>
<
body>
<
div class="header">
Header Text
</div>
<
div class="container">
<
div class="left">
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left
left left left left left left left left left left left left

</div>
<
div class="center">
center
</div>
<
div class="right">
right
</div>
</
div>
<
div class="footer">
Footer Text
</div>
</
body>
</
html>



OUTPUT

image

Suggestions are welcome!






About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

No comments: