Bootstrap navbar-btn 類的用法


要將按鈕新增到不位於 <form> 中的 <button> 元素以將它們垂直居中在導航欄中,請使用類的 .navbar-btn 。可以將 .navbar-btn 用在 <a> 和 <input> 元素上。

你可以嘗試執行以下程式碼來實現 navbar-btn 類

示例

線上示例

<!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: #85C1E9;">
         <div class = "navbar-header">
            <a class = "navbar-brand" href = "#">Search below:</a>
         </div>
         <div>
            <form class = "navbar-form navbar-left" role = "search">
               <div class = "form-group">
                  <input type = "text" class = "form-control" placeholder = "Search">
               </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>

更新日期: 12-Jun-2020

442 人檢視

開啟你的職業生涯

完成課程,獲得認證

開始
廣告
© . All rights reserved.