导航栏中“溢出:隐藏”的含义

时间:2019-02-08 14:53:02

标签: html css overflow

我一直在导航栏中看到声明“ overflow:hidden”,但我不明白它如何改变背景颜色。我仅将属性理解为处理边界以外内容的事物,即您可以应用滚动,隐藏它们或将它们保持原样。它是如何做的?

* {
  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>

0 个答案:

没有答案