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%;">
  <p>Insidediv
  <br><br><br><br><br><br>
  maindiv should expand dynamically based on the content of this div, and it should fully enclose this div
  </p>
  </div>
  </div>

2 answers

1
point
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 almost 9 years ago by Jens Hedqvist
BPartch 342
1
point

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

.maindiv{overflow:hidden}

Answered almost 9 years ago by BPartch