0

HTML

<body>
    <div class="parent">
      <div class="red">1</div>
      <div class="green">2</div>
    </div>
</body>

Styles

.red {
  width: 150px;
  height: 150px;
  background-color: red;
}
.green {
  width: 150px;
  height: 150px;
  background-color: green;
}
.parent {
  background-color: yellow;
}

Output enter image description here

When I add float left to red class, I am getting the below output. enter image description here

May I know why the content of green div is overflowing outside of the parent div when I float the red div?

SureN
  • 752
  • 7
  • 13

0 Answers0