Grow your CSS skills. Land your dream job.

expand div’s height to fit its container

  • # November 27, 2012 at 4:15 pm

    Hi:
    I have a container div with two inner divs, one below the other(not floated), and the first inner div with a fixed height. The question is: how can I make the second div to expand its height to fit its parent?

    # November 27, 2012 at 4:40 pm

    I am not understanding what you are trying to accomplish. can you show us your code?

    # November 27, 2012 at 9:05 pm

    Its parent is only as tall as the two child divs, unless you’ve set a height.

    # November 27, 2012 at 10:48 pm

    Got it completely, so here you go http://codepen.io/anon/pen/qBneu

    Keep in mind it isn’t fool proof and has some pitfalls

    # November 28, 2012 at 1:12 am

    @Schwarttzy – .container needs to be height: 400px; not min-height: 400px;. Do that, and it works.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".