Solved

3 Column CSS Layout (fluid width - fixed width - fluid width) Body Height 100%

Posted on 2008-06-25
2
2,182 Views
Last Modified: 2008-07-02
I'm having a problem with my CSS layout. I am trying to do a simple 3-column layout with a left-center-right design. Left column has a fluid width. Center column has a fixed width of 800px. Right column has a fluid width.

In my design, the center div will have a varying height depending on the page. I need the other two columns (left and right) to set themselves to be 100% of the height of the center column at all times. So, if the content within the center column changes, the left and right column should adjust to be 100% height of the center column.

I have tried to put height: 100% in the body tag, but this does not work. The only way I can get it to work is by specifying a static height for the center column (height: 800px).


My question:
Assuming that my center div will constantly change height, what is the best way to have my left and right columns automatically adjust themselves to the height of the center column?

Please see my complete page css below.

Thank you in advance for any help you may be able to offer!

=)







<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>html</title>
<style type="text/css">
body {
	/*height:800px;*/
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
#col_left {
	height:100%;
	width: 49.9%;
	margin-right: -400px;
	float: left;
 
}
#col_left .liner {
	height:100%;
	background-color:#E4E2D8;
	background-image:url(images/background_left1.gif);
	background-repeat:repeat-y;
	background-position:right;
	margin-right: 400px;
	border-right: solid 1px #000000;
}
#col_right {
	height:100%;
	width: 49.9%;
	margin-left: -400px;
	float: left;
}
#col_right .liner {
	height:100%;
	background-color:#E4E2D8;
	background-image:url(images/background_right1.gif);
	background-repeat:repeat-y;
	background-position:left;
	margin-left: 400px;
	border-left: solid 1px #000000;
}
#col_center {
	height:100%;
	width: 800px;
	float: left;
	border-bottom: solid 1px #000000;
}
 
</style>
</head>
<body>
 <div id="col_left">
   <div class="liner">Left (fluid width)</div>
</div>
 <div id="col_center">
       Center- (static: 800 pixels wide)
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
         <br />
 </div>
<div id="col_right">
   <div class="liner">Right (fluid width)</div>
</div>
</body>
</html>

Open in new window

0
Comment
Question by:ChimneySupply
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 21868641
Some good info here:
http://www.sitepoint.com/newsletter/viewissue.php?id=3&issue=70

And here:
http://www.dave-woods.co.uk/?p=144

A good idea might be to use a footer that is 100% width of the three columns.  The sitepoint newsletter might be just the trick.  

HTH, ~Ray
0
 

Author Comment

by:ChimneySupply
ID: 21916643
Ray -

Thank you very much for the articles. the first article (sitepoint.com) seemed to solve it for me. I created a simple Javascript function that reads the height of the center div, then sets the left and right div height to match.

Thanks again!

=)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Angular JS Sticky Footer Problem (when page size doesn't meet minimum) 4 64
removing a class in javascript 4 97
Wordpress themes CSS? 6 41
Firefox CSS Help. 1 14
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question