0

Recently experiment with float and found overflow: hidden behaviour difficult to understand.

.child {
 width: 100px;
 height: 200px;
 background-color: #afe;
 overflow: hidden;
}

img.fl {
 float: left;
}
<img class="fl" src="./images/bdlogo.png">
<div class="child">
</div>

When there is "overflow: hidden" in child class, div child will not be overlayed by the picture floated. But if I delete "overflow:hidden", div child will be hidden by the floated picture.

Ferrmolina
  • 2,737
  • 2
  • 30
  • 46

1 Answers1

0

CSS overflow:hidden with floats

Plz visit this link and note down the last second answer which is the answer to your question. Setting overflow: hidden on an element causes a new float context to be created, so elements that are floated inside an element that has overflow: hidden applied are cleared. You can also visit http://jasonkinney.me/power-css-overflow-hidden/

Community
  • 1
  • 1
Amanjot Kaur
  • 2,028
  • 4
  • 18
  • 33
  • Amanjot, Thanks for your answer, so it is because overflow:hidden create a new BFC and BFC prevent its content from being overlay. – Vera Lyu Jun 30 '15 at 01:25