2

在此处输入图像描述我有以下 html 代码,它给了我一个像附加屏幕截图一样的页面。我想将搜索字形图标与搜索框一起固定在右端角。
代码在这里:

<!DOCTYPE html>
<html>
  <head>
    <title>Bootstrap 101 Template</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->

    <link href="../css/bootstrap.min.css" rel="stylesheet" media="screen">
    </head>

  <body>
    <nav class="navbar navbar-default" role="navigation">
  <!-- Brand and toggle get grouped for better mobile display -->
  <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="#">Hello World</a>
  </div>

  <!-- Collect the nav links, forms, and other content for toggling -->
  <div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul class="nav navbar-nav navbar-right">
      <li class="active"><a href="#">Welcome</a></li>
      <li><a href="#">Login</a></li>
      <li><a href="#">Signup</a></li>
      <li>

    <form class="navbar-form" role="search"> <li> 
        <input type="text" class="form-control" placeholder="Search"></li>
        <li>
      <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button></li>

    </form>
    <li>
    </ul>

  </div><!-- /.navbar-collapse -->
</nav>
    <form>
        <fieldset class='textbox' style="padding:10px">
                   <input style="margin-top: 8px" type="text" placeholder="Username" /><br/>
                   <input style="margin-top: 8px" type="password" placeholder="Passsword" /><br/><br/>
                   <input class="btn btn-primary" name="commit" type="submit" value="Log In" />
                 </fieldset>
             </form>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>

  </body>
</html>

有人可以帮助解决这个问题吗?

谢谢在此处输入图像描述

4

1 回答 1

1

使用form-group..

<form class="navbar-form  navbar-right" role="search"> 
      <div class="form-group">
         <input type="text" class="form-control" placeholder="Search">
      </div>
      <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</form>

演示:http ://bootply.com/78702

于 2013-10-29T14:10:41.513 回答