使用 CSS 建立水平導航欄


要建立一個水平導航欄,將<li>元素設定為內聯。

示例

你可以嘗試執行以下程式碼來建立水平導航欄

即時演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
         }
         .active {
            background-color: #4CAF50;
            color: white;
         }
         li {
            border-bottom: 1px solid #555;
            display: inline;
         }
      </style>
   </head>
   <body>
      <ul>
         <li><a href = "#home">Home</a></li>
         <li><a href = "#company" class = "active">Company</a></li>
         <li><a href = "#product">Product</a></li>
         <li><a href = "#services">Services</a></li>
         <li><a href = "#contact">Contact</a></li>
      </ul>
   </body>
</html>

更新於:01-Jul-2020

3K+ 瀏覽

開啟你的事業

透過完成課程獲得認證

開始
廣告
© . All rights reserved.