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.