How to make floated divs height equal

topic posted Sat, October 17, 2009 - 9:58 AM by  SMSapphire
Share/Save/Bookmark
Advertisement
Hey all~

I've recently been converting an old table-based website to XHTML & CSS and have run into a snag. The main content area is a 3-column layout, so I've set it up as 3 divs that are floated left. The issue is that the most content is in the center div, so it's longer than the outer columns and I want to find a way to make the left and right divs extend down so the bottom of all 3 columns line up.

So far I've tried using min-height, and setting the top and bottom margins to 0, but nothing works.

Anyone have any luck with this sort of thing?
Advertisement
Advertisement
  • Re: How to make floated divs height equal

    Sat, October 17, 2009 - 11:51 PM
    If your site is a fixed width, you can fake it by creating a background image to make it look like borders.
    Create a background image the width of your site by a few pixels high then repeat it vertically.

    Something like this.

    <div style="width: 600px; background-image:url(borders.jpg); background-repeat:repeat-y;">
    <div style="float:left">blah</div>
    <div style="float:left">blah blah blah blah</div>
    <div style="float:left">blah</div>
    </div>

    The only other way I know how is with javascript.

    Good luck
    • Re: How to make floated divs height equal

      Mon, October 19, 2009 - 1:46 AM
      my first guess would be to put them into a 'parent' div and then make the three 'child' divs have 100% height.
      then create a fourth 'child' div with a css style of 'clear:both'. I've not tried it but it would be my best guess.

      so like this:

      <div>
      <div class='child'>blah blah</div>
      <div class='child'>blah blah</div>
      <div class='child'>blah blah</div>
      <div class='clear'></div>
      </div>

      .child {
      height:100%;
      float:left;
      }

      .clear {
      clear:both;
      }

Recent topics in "Web Design"

Topic Author Replies Last Post
RSS News aggregator offlineJAKEYERBOOTY 3 October 23, 2009
Actionscript for linking to a URL Unsubscribed 6 September 26, 2009
32-bit integer to RGB hex conversion Jesse 1 September 11, 2009
Entire Site In Flash? Unsubscribed 3 September 11, 2009
Quality website templates Eyesys 4 September 11, 2009