0

I keep seeing the declaration "overflow: hidden" in navbars and I don't understand how it changes the background color. I only understand the property as something that deals with things outside of the border i.e you can apply the scroll, hide them, or leave them as is. How is it doing what it is doing?

* {
  box-sizing: border-box;
}


/* Style the top navigation bar */

.topnav {
  overflow: hidden;
  background-color: #333;
}


/* Style the topnav links */

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}


/* Change color on hover */

.topnav a:hover {
  background-color: #ddd;
  color: black;
}


/* On screens that are 600px wide or less, make the menu links stack on top of each other instead of next to each other */

@media screen and (max-width: 600px) {
  .topnav a {
    float: none;
    width: 100%;
  }
}
<h2>Responsive navigation menu</h2>
<p>Resize the browser window to see the effect: When the screen is less than 600px, the navigation menu will be displayed vertically instead of horizontally.</p>

<div class="topnav">
  <a href="#">Link</a>
  <a href="#">Link</a>
  <a href="#">Link</a>
</div>
j08691
  • 204,283
  • 31
  • 260
  • 272
Kevvv
  • 3,655
  • 10
  • 44
  • 90

0 Answers0