2015-06-16 72 views
3

我想創建我的品牌在左邊,中間全寬搜索欄,並在右側其他一些頁面的導航欄導航欄引導搜索。 當頁面被一個小屏幕上觀看我想要的搜索欄是在同一個地方,全寬,坍塌菜單之外。外崩潰

我在與獲得的搜索欄全寬度不推右邊我的網頁到另一行的問題,我當頁面是移動格式也無法得到在同一行上的搜索欄。

這是它的外觀與小屏幕尺寸:

This is how it looks with a small screen size

這是我使用的導航欄的代碼,CSS的只是標準的引導3.

<nav class="navbar navbar-default navbar-fixed-top"> 
    <div class="container"> 
     <div class="row"> 
      <span> 
       <div class="navbar-header"> 
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> 
         <span class="icon-bar"></span> 
         <span class="icon-bar"></span> 
         <span class="icon-bar"></span> 
        </button> 
        <a class="navbar-brand" href="#">logo</a> 
       </div> 

       <form class="navbar-form"> 
         <div class="form-group" style="display:inline;"> 
          <div class="input-group" style="display:table;"> 
           <input class="form-control" name="search" placeholder="Search Here" autocomplete="off" type="text"> 
           <span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span> 
          </div> 
         </div> 
       </form> 

      </span> 
      <span> 
       <div class="navbar-collapse collapse"> 
        <ul class="nav navbar-nav navbar-right"> 
         <li><a href="about.html">About</a></li> 
         <li id="userPage"> 
          <a href="#@userpage"><i class="icon-user"></i> My Page</a> 
         </li> 
         <li><a href="#logout" data-prevent="">Logout</a></li> 
        </ul> 
        </ul> 
       </div> 
      </span> 
     </div> 
    </div> 
</nav> 

Here is a jsfiddle with my code so far on it.

任何幫助,將不勝感激!

回答

0

這將爲你 -

<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script> 
 
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/> 
 

 

 
<nav class="navbar navbar-default" role="navigation"> 
 
\t <div class="row"> 
 
\t \t <div class="col-sm-9 col-md-9"> 
 
\t \t \t <div class="navbar-header"> 
 
\t \t \t \t <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
 
\t \t \t \t \t <span class="sr-only">Toggle navigation</span> 
 
\t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t </button> 
 
\t \t \t \t <a class="navbar-brand" href="#">Company Name</a> 
 
\t \t \t </div> 
 
\t \t \t <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
 
\t \t \t \t <ul class="nav navbar-nav"> 
 
\t \t \t \t \t <li class="active"><a href="#">Link</a></li> 
 
\t \t \t \t \t <li><a href="#">Link</a></li> 
 
\t \t \t \t \t <li class="dropdown"> 
 
\t \t \t \t \t \t <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a> 
 
\t \t \t \t \t \t <ul class="dropdown-menu"> 
 
\t \t \t \t \t \t \t <li><a href="#">Action</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Another action</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Something else here</a></li> 
 
\t \t \t \t \t \t \t <li class="divider"></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Separated link</a></li> 
 
\t \t \t \t \t \t \t <li class="divider"></li> 
 
\t \t \t \t \t \t </ul> 
 
\t \t \t \t \t </li> 
 
\t \t \t \t </ul> 
 
\t \t \t </div> 
 
\t \t </div> 
 
\t \t <div class="col-sm-3 col-md-3 pull-right"> 
 
\t \t <form class="navbar-form" role="search"> 
 
\t \t \t <div class="input-group"> 
 
\t \t \t \t <input type="text" class="form-control" placeholder="Search" name="q"> 
 
\t \t \t \t <div class="input-group-btn"> 
 
\t \t \t \t <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button> 
 
\t \t \t \t </div> 
 
\t \t \t </div> 
 
\t \t </form> 
 
\t \t </div> 
 
\t </div> 
 
</nav>

+0

這是類似的工作,但我想可摺疊菜單之外的搜索框時,屏幕較小。 –

+0

然後用此琴http://jsfiddle.net/y4m529ff/7/ –

+0

檢查與編輯的代碼@adamb去 –