透過 Bootstrap 將導航欄固定到頂部


將導航欄固定到頂部,向 .navbar 類新增類 .navbar-fixed-top。

你可以嘗試執行以下程式碼,將導航欄固定到頂部

示例

即時演示

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <nav class = "navbar navbar-default navbar-fixed-top" role = "navigation" style="background: red;">
         <div class = "navbar-header">
            <a class = "navbar-brand" href = "#">Modes of Transport</a>
         </div>
         <div>
            <ul class = "nav navbar-nav">
               <li class = "active"><a href = "#">Air Transport</a></li>
               <li><a href = "#">Water Transport</a></li>
            </ul>
         </div>
      </nav>
   </body>
</html>

更新於: 2020 年 6 月 12 日

已瀏覽 4K+ 次

開啟你的職業生涯

完成課程,獲得認證

開始學習
廣告
© . All rights reserved.