views:

371

answers:

3

In CSS, I can do something like this:

alt text

But I've no idea how to change that to something like:

alt text


Is this possible with CSS?

If yes, how can I do it without explicitly specifying the height (let the content grow)?

+4  A: 

Yes. http://matthewjamestaylor.com/blog/perfect-3-column.htm

This isn't the only method for doing it, but this is probably the most elegant method I've encountered.

Edit: Here's another: http://www.manisheriar.com/holygrail/index.htm

Edit: Article: http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks

Edit: Woops. First link was supposed to be this: http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks

Joel Etherton
It seems the link you provided is related to the width, not height. Am I wrong?
Alix Axel
No it covers height as well.
Joel Etherton
Nice, found it! I think you mean http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks
Alix Axel
Yah. Looks like I had the wrong end point in the clipboard. D'oh.
Joel Etherton
+1  A: 

You can do this with JQuery

$(window).load(function() {
    //call the equalize height function
    equalHeight($("div.left, div.middle, div.right"));

    //equalize funciton
    function equalHeight(group) {
        tallest = 0;
        group.each(function() {
            thisHeight = $(this).height();
            if(thisHeight > tallest) {
                tallest = thisHeight;
            }
        });
        group.height(tallest);
    }
}); 
Alexander
+1. Yay for jQuery hacks!
littlegreen
Hack it is, this'll do until CSS tables are the norm :D
Alexander
+2  A: 

You could use CSS tables, like so:

<style type='text/css">
    .container { display: table; }
    .container .row { display: table-row; }
    .container .row .panel { display: table-cell; }
</style>
<div class="container">
    <div class="row">
        <div class="panel">...text...</div>
        <div class="panel">...text...</div>
        <div class="panel">...text...</div>
    </div>
</div>
K Prime
Not supported by a some browsers, though.
Joel Coehoorn
Seems promising, **/me tries it out**.
Alix Axel
@Joel Coehoorn: Do you know which ones? It would be useful to know.
Alix Axel
+1, I would prefer this approach over the one provided by Joel. But it seems to have problems with some browsers (still **I would like to know which ones**).
Alix Axel
@Alix - I know for certain that IE6/7 doesn't support `display:table` - others have issues if you don't use explicit table, row, and cells (as in, using anonymous elements (http://www.digital-web.com/articles/everything_you_know_about_CSS_Is_wrong/), etc.)
K Prime
@Alix - some reference on cross-browser issues: http://www.quirksmode.org/css/display.html#table
K Prime