如何创建:底部导航

学习如何使用 CSS 创建底部导航菜单。

亲自试一试

创建底部导航菜单

第一步 - 添加 HTML:

<div class="navbar">
  <a href="#home" class="active">Home</a>
  <a href="#news">News</a>
  <a href="#contact">Contact</a>
</div>

第二步 - 添加 CSS:

/* 将导航栏放在页面底部,并使其固定 */
.navbar {
  background-color: #333;
  overflow: hidden;
  position: fixed;
  bottom: 0;
  width: 100%;
}

/* 设置导航栏中链接的样式 */
.navbar a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* 更改鼠标悬停时链接的颜色 */
.navbar a:hover {
  background-color: #ddd;
  color: black;
}

/* 为活动/当前链接添加颜色 */
.navbar a.active {
  background-color: #04AA6D;
  color: white;
}

亲自试一试

相关页面

教程:CSS 导航栏

教程:如何创建响应式底部导航