在 Bootstrap 導航欄中新增按鈕


透過類 .navbar-btn 為 <button> 元素新增按鈕。你可以嘗試執行以下程式碼,將按鈕新增到導航欄

示例

現場演示

<!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" role = "navigation" style="background: red;color:white;">
         <div class = "navbar-header">
            <a class = "navbar-brand" href = "#">Example</a>
         </div>
         <div>
            <form class = "navbar-form navbar-left" role = "search">
               <div class = "form-group">
                  <input type = "text" class = "form-control" placeholder = "Search here...">
               </div>
               <button type = "submit" class = "btn btn-default">Submit Button</button>
            </form>
            <button type = "button" class = "btn btn-default navbar-btn">Navbar Button</button>
         </div>
      </nav>
   </body>
</html>

更新於: 2020 年 6 月 12 日

2K+ 瀏覽量

開啟你的 事業

透過完成課程獲得認證

開始
廣告