Search code examples
csspositioning

Using CSS to position div's held in a parent div and the content below it


I am trying to use css to position two div's, one directly above the other. This usually works fine except the height of the div on top has a dynamic height as content is added or taken away using javascript. Inside of that div I have a series of other div's but the parent div does not expand to cover the ones inside of it. I need a way to make the div on top expand in size to cover every child it has.

And help or alternate solutions would be awesome.


Solution

  • This is most likely caused by having floated elements inside of your div. You can either add a clearing div at the end of its contents with style clear:both; or add overflow:hidden; to the dynamic height div

    This is explained in detail on Quirksmode