How to make two columns have the same height?

Show off new creations, get help, or just chat about all aspects of web development and design.

How to make two columns have the same height?

Postby Psy on Wed Jun 25, 2008 7:35 pm

I'm currently creating a website with two floating DIVs which act as columns. What I need is for the columns to extend to the same height as shown by the red line in the image below.

Image

HTML Code.

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<HTML>

<HEAD>
<title>Aaron Garcha - Level Designer</title>
<link href="style.css" rel="stylesheet" type="text/css">

</HEAD>

<BODY>
<div id="wrapper">

   
      <div id="left">
         
         <img src="images/top.png" width="250px" height="32px" />
      
         <div id="left-content">
         
            <div id="logo"></div>
         
            <div id="spacer"></div>
         
            <p><b>CONTACT:</b></p>
            <p>aaronftw@gmail.com</p>
         
            <p><b>AREA OF EXPERTISE</b></p>
            <p>Level Design</p>
         
            <p><b>EXPERIENCE</b></p>
            <p>
               3 years with Hammer<br />
               5 years with 3DS Max<br />
               2 years with Photoshop CS2<br />
            </p>
            
      
         </div>
         

         
      </div>
      
      <div id="right">
      
         <img src="images/top.png" width="250px" height="32px" />
         
         <div id="right-content">
      
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         <img src="images/null.png" width="75px" height="75px" />
         
         </div>
         

         
      </div>   
      
      <div class="clear">&nbsp;</div>
</div>
</BODY>

</HTML>


CSS:

Code: Select all
body {
font-family: sans-serif;
background-color: #cadceb;
}

html, body {height:100%;}

#wrapper {
width: 550px;
height: 525px;
margin-left: auto;
margin-right: auto;
padding-top: 20px;
position: relative;
}

#spacer {
height: 25px;
}

#logo {
width: 200px;
height: 200px;
border: 1px black solid;
margin-left: auto;
margin-right: auto;
}

#left {
float: left;
width: 250px;
height: 800px;

}

#left-content {
background-color: white;
border: 4px #098fd1 solid;
border-top: 0;
}

#right{
float: right;
height: 800px;
width: 250px;
}

#right-content {
background-color: white;
border: 4px #098fd1 solid;
border-top: 0;
text-align: center;
vertical-align: center;
}

h1 {
font-size: 12px;
text-align: center;
}

p {
padding-left: 20px;
font-size: 11px;
line-height: 1.5;
}

hr {
height: 2px;
width: 660px;
}

#images {
text-align: center;
}
User avatar
Psy
Veteran
Veteran
 
Joined: Sat Dec 03, 2005 5:41 pm
Location: United Kingdom

Re: How to make two columns have the same height?

Postby zombie@computer on Wed Jun 25, 2008 8:04 pm

height=100% ?
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: How to make two columns have the same height?

Postby Blink on Thu Jun 26, 2008 12:03 am

Floats will only ever extend as far as their content. Try searching Google for Faux columns, there are tonnes of guides but here is the top result:

http://www.alistapart.com/articles/fauxcolumns/
User avatar
Blink
Cool 'n that
Cool 'n that
 
Joined: Fri Oct 08, 2004 4:16 pm
Location: UK

Re: How to make two columns have the same height?

Postby Jest@ on Thu Jun 26, 2008 10:02 pm

If you want them to be as high as the browser window, setting height:100% works (set it on body & html tags as well). Then, to make room for the header and footer, use negative margin values. But some form of faux columns is usually appropriate; do you really need them to stretch all the way down? if it's for background/border/rounded corner purposes, just faux-column fake it. If you want reeeeally them to be as high as whichever column has the longest content, you will have a bigger task on your hand - IIRC, it is just about possible, but I can't remember how. If it is, I'm 99% certain it'll require some torturous markup
Highlight to read:
It was earth all along
User avatar
Jest@
Veteran
Veteran
 
Joined: Mon Nov 22, 2004 1:50 am
Location: London UK

Re: How to make two columns have the same height?

Postby Blink on Thu Jun 26, 2008 11:01 pm

height 100% won't work on floats, they just wrap round their content and even then the container has to be floated or cleared using various tricks.

Tis why faux columns were invented.
User avatar
Blink
Cool 'n that
Cool 'n that
 
Joined: Fri Oct 08, 2004 4:16 pm
Location: UK

Re: How to make two columns have the same height?

Postby Jest@ on Thu Jun 26, 2008 11:41 pm

Blink wrote:height 100% won't work on floats, they just wrap round their content and even then the container has to be floated or cleared using various tricks.

Tis why faux columns were invented.


Ah, duh, 'tis true. If you want full browser window height, you can do it my way (height:100% with negative margins) by not floating the divs, and instead using position:relative for the left-hand, and position:absolute, right:0px for the right-hand one. But of course that comes with all the baggage of absolute positioning.
Highlight to read:
It was earth all along
User avatar
Jest@
Veteran
Veteran
 
Joined: Mon Nov 22, 2004 1:50 am
Location: London UK

Re: How to make two columns have the same height?

Postby zombie@computer on Fri Jun 27, 2008 11:47 am

oh, wait, we were floating. my bad
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Return to Web Design & Development

Who is online

Users browsing this forum: No registered users

cron