The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Parent div won't resize vertically to take account of child divs

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #192089

    I have read a lot of similar problems on other forums but none of them seem to solve the problem I’m having.

    Below is the basic structure:


    I have tried everything but at the moment:

    1) the wrapper div is positioned absolutely (in relation to the page)and has a set width.

    2) main_container div is relative (in relation to the wrapper div) which means its exactly the same size as the wrapper.

    3) child divs positioned absolutely (in relation to main_container div)


    main_container div is not resizing vertically based on child divs. It only seems to resize based on

    etc. elements inside it but that are not inside a child div. Why is this? THe positioning is working, its just it doesn’t take acount of the child divs contents.

    I don’t want to start using any floats etc. Also, setting a minimum height for the main_container div defeats the the aim of having it resize vertically based on content.

    Any ideas?


    Absolutely positioned elements are taken out of the flow and do not count towards their parent’s height. That’s the point of absolute positioning

    Positioning is a very poor way of laying out a website and is very unforgiving and definitely unresponsive.

    There are much better methods –

    I don’t want to start using any floats etc.

    I don’t know why, it’s a perfectly acceptable layout method but there are others.

    They all have their issues but using positioning is intended (at least these days) for specific effects not supported by the ‘standard’ layout methods.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.