Omu 0

the problem is that the maindiv doesn't expand accordingly to insidediv when insidediv has the fload attribute

  <div id="maindiv" style="border:2px solid red;">
  <p>main Div that needs to expand based on content of "insidediv"</p>
  <div id="insidediv" style="border:1px solid blue; float: left; width: 100%;">
  maindiv should expand dynamically based on the content of this div, and it should fully enclose this div

2 answers

This was chosen as the best answer

Because the "insidediv" is floated, it no longer takes up space in the normal flow of the document, therefore the "maindiv" doesn't recognize it at all. The easiest way to work around this is to add "overflow: hidden" to the "maindiv". There are other methods out there as well. Google "Clear Floats" or similar.

Good luck!

Answered about 9 years ago by Jens Hedqvist
BPartch 342

Make sure there is no height set on maindiv and add the following overflow property to the selector.


Answered about 9 years ago by BPartch