treehouse : what would you like to learn today?
Web Design Web Development iOS Development

div height:100% of div height:auto?

  • Anybody ever figure this out?

    For instance:
    <div>
    <div style="float:left; height:100%;"></div>
    <p>blah</p>
    <p>blah</p>
    <p>blah</p>
    </div>



    Obviously that isn't going to work but how do you MAKE it work? :P

    In other words(image), how do you achieve THIS:
    click me!!!11
  • If you actually want the wrapping div to be visible - say like you have a background you need to display - then you can do it like this:


    <div style="background:green; height:auto; overflow:hidden">
    <div style="float:left; height:100%;"></div>
    <p>blah</p>
    <p>blah</p>
    <p>blah</p>
    </div>


    If you are talking about making the div 100% to the inside of actual wrapping div and that wrapping div being dynamic - you're best doing that with a little Javascript : )
  • Last time i tried with Javascript, the only idea I got was to find the height of the div but since it's auto I always got undefined back. Is this the case?

    EDIT: Ummm nevermind, I'm stupid..

  • $(".article_img").load(function () {
    var aheight = $("#a").css("height");
    alert(aheight);
    });


    Works great. :)
  • If you can use JavaScript, that's great. Otherwise there are lots of fancy CSS solutions. Try googling up "Equal Height Columns"
  • thanks chris