Bootstrap3:在移动浏览器中右侧的navbar-form float和输入表单的边距

时间:2014-12-15 08:50:44

标签: html css twitter-bootstrap

我使用bootstrap3有两个关于navbar的问题

  1. 以下代码<form class="navbar-form navbar-right" role="form">
    将类设置为navbar-right。但这些形式没有正确行动 (此外,无论班级名称是导航栏左侧还是导航栏右侧,这些表格都无法移动。)

  2. 在移动浏览器中,2个表单无法完全显示,特别是其宽度(两侧)被剪切。


  3.     我怎么解决他们?

    提前谢谢。

    http://www.bootply.com/tanJWih5tr

            <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
              <div class="container">
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  </button>
                  <a class="navbar-brand" href="#">Brand</a>
                 </div>
                <div class="collapse navbar-collapse navbar-ex1-collapse">
                  <ul class="nav navbar-nav">
                    <li><a href="#">Menu1</a></li>
                    <form class="navbar-form navbar-right" role="form">
                    <!-- i already set class "navbar-right", but these forms don't align to right -->        
                      <div class="form-group">        
                        <label class="sr-only" for="exampleInputEmail2">Email address</label>        
                        <input type="email" class="form-control" id="exampleInputEmail2" placeholder="Enter email">        
                      </div>        
                      <div class="form-group">        
                          <label class="sr-only" for="exampleInputPassword2">Password</label>        
                          <input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password">        
                      </div>        
                      <button type="submit" class="btn btn-info">Sign in</button>        
                    </form>        
                  </ul>        
                </div>        
              </div>
            </nav>
    

1 个答案:

答案 0 :(得分:1)

您已将代码<ul>关闭在错误的位置。

这样做

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav">
        <li><a href="#">Menu1</a></li>
      </ul>
      <form class="navbar-form navbar-right" role="form"> <!-- i already set class "navbar-right", but these forms don't align to right -->
        <div class="form-group">
          <label class="sr-only" for="exampleInputEmail2">Email address</label>
          <input type="email" class="form-control" id="exampleInputEmail2" placeholder="Enter email">
        </div>
        <div class="form-group">
          <label class="sr-only" for="exampleInputPassword2">Password</label>
          <input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password">
        </div>
        <button type="submit" class="btn btn-info">Sign in</button>
      </form>
    </div>
  </div>
</nav>