如何創建:底部導航

學習如何使用 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 導航欄

教程:如何創建響應式底部導航