Bootstrap全宽搜索框

时间:2015-07-22 13:18:07

标签: html css twitter-bootstrap

我尝试制作全宽搜索框。它在标签和移动设备上工作但不能在台式机或笔记本电脑上工作

这是我的代码

<div class="row">
<div class="col-md-offset-2 col-sm-offset-2 col-xs-offset-1 col-md-8 col-sm-8 col-xs-10">    
<form action="" autocomplete="off" class="navbar-form" method="post" accept-charset="utf-8">
        <div class="input-group">
            <input name="searchtext" value="" class="form-control" type="text">
            <span class="input-group-btn">
               <button class="btn btn-default" type="submit" id="addressSearch">
                   <span class="icon-search"></span>
               </button>
            </span>
        </div>
    </form>
</div>
</div>

当我看到响应式视图在移动设备和标签视图上工作时 enter image description here

但它不适用于桌面视图 enter image description here

3 个答案:

答案 0 :(得分:11)

删除nav-bar类并添加form-horizo​​ntal

<form action="" autocomplete="off" class="form-horizontal" method="post" accept-charset="utf-8">
        <div class="input-group">
            <input name="searchtext" value="" class="form-control" type="text">
            <span class="input-group-btn">
               <button class="btn btn-default" type="submit" id="addressSearch">
                   <span class="icon-search"></span>
               </button>
            </span>
        </div>
    </form>

答案 1 :(得分:1)

将col-lg-12类赋予div

<form action="" autocomplete="off" class="navbar-form" method="post" accept-charset="utf-8">
<div class="input-group col-lg-12">
    <input name="searchtext" style="width:100%" value="" class="form-control" type="text">
    <span class="input-group-btn">
       <button class="btn btn-default" type="submit" id="addressSearch">
           <span class="icon-search"></span>
       </button>
    </span>
</div>

答案 2 :(得分:-1)

<div class="row">
   <div class="col-md-offset-2 col-sm-offset-2 col-xs-offset-1 col-xs-10 col-sm-8 col-md-8 col-lg-6">
     <div class="form-group">
        <input name="searchtext" value="" class="form-control" type="text">
        <span class="input-group-btn">
           <button class="btn btn-default" type="submit" id="addressSearch">
               <span class="icon-search"></span>
           </button>
        </span>
    </div>
   </div>
</div>