1

In this example of a drop down menu navigation bar at w3school, when all the li elements gets float: left;, the background-color of ul is gone, but adding overflow: hidden; brings it back. How does that work?

Vun-Hugh Vaw
  • 180
  • 1
  • 7

1 Answers1

1

The float: left removes li elements from the flow inside ul element. Since li are the only children of ul. 'ul' does not contain "anything" therefore no background. overflow: hidden is a technique similar to "clearfix" to force containment of float children.

Have a read on this link - Simple Tips on Containing Floats