0

你可以看到它live here如何讓這個Bootstrap導航欄在移動設備上看起來整潔?

下面是截圖移動:

Messed-up Mobile Navbar Bootstrap

這裏是無菌HTML:

<header class="header"> 
     <hgroup class="pull-left"> 
     <h1 class="site-title"> 
      <a rel="home" title="Von" href="index.html"> 
      <i class="fa fa-lemon-o"></i> Von 
      </a> 
     </h1> 
     </hgroup> 
     <div id="togglesidebar" class="btn btn-primary pull-right"> 
     <i class="fa fa-bars"></i> 
     </div> 

       <!-- Single button --> 
       <div class="btn-group"> 
        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 
        Action <span class="caret"></span> 
        </button> 
        <ul class="dropdown-menu" role="menu"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider"></li> 
        <li><a href="#">Separated link</a></li> 
        </ul> 
       </div> 

      <!-- Search Bar --> 
      <div class="container"> 
       <div class="row"> 
        <div class="col-xs-6 col-xs-offset-2"> 
         <div class="input-group"> 
          <div class="input-group-btn search-panel"> 
           <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 
            <span id="search_concept">Filter by</span> <span class="caret"></span> 
           </button> 
           <ul class="dropdown-menu" role="menu"> 
            <li><a href="#contains">Contains</a></li> 
            <li><a href="#its_equal">It's equal</a></li> 
            <li><a href="#greather_than">Greather than ></a></li> 
            <li><a href="#less_than">Less than < </a></li> 
            <li class="divider"></li> 
            <li><a href="#all">Anything</a></li> 
           </ul> 
          </div> 
          <input type="hidden" name="search_param" value="all" id="search_param"> 
          <input type="text" class="form-control" name="x" placeholder="Search term..."> 
          <span class="input-group-btn"> 
           <button class="btn btn-default" type="button"><span class="glyphicon glyphicon-search"></span></button> 
          </span> 
         </div> 
        </div> 
       </div> 
      </div> <!-- /search-bar --> 
    </header> <!-- /header --> 

在真人版,標誌是153px X 50px

更新1:

Darshak號的建議之後,這是移動版本的樣子。更好,但仍需要調整。

Mobile-Menu-Responsive

+0

你可能想發表您的CSS問更好的問題。只要看看HTML,就很難回答你的問題。你使用默認的引導程序的CSS?某種類型的主題?只是你的HTML不完全有用。 – JohnSalzarulo 2014-09-26 03:49:11

+0

我正在使用Bootstrap和一個主題。這就是爲什麼我發佈了一個實時鏈接,所以你可以看到它的行動 - 將有太多的CSS顯示。無論如何,我相信核心問題是與Bootstrap相關的類。 HTML中沒有很多主題特定的類。 – marcamillion 2014-09-26 03:58:43

+2

首先,你要加載所有CSS文件兩次並編譯成一個文件,然後在所有文件之後加載標準化(並在該文件中編譯)。所以基本上,你聲明瞭一個類,然後通過重新聲明它來使其無效,然後,爲了防止任何Bootstrap類的選擇與normalize.css一起使用,以防萬一。清理該文件,很可能您不需要執行其他任何操作 – Devin 2014-09-26 04:01:54

回答

1

試試這個。我嘗試對您的設計進行響應式外觀,並在您的結構中修改某些類。 我把這個結構放在你給定的鏈接上。

<header class="header clearfix"> 
 
    <div class="row masthead clearfix"> 
 
    <hgroup class="col-xs-6 col-sm-6 col-md-3 col-lg-3"> 
 
     <div class="site-title"> 
 
     <a href="/"> 
 
      <img alt="Ognrlogo" height="50" src="/assets/ognrlogo-232e94e86f40eeb3021490f5cf1e1a48.png" width="153" class="img-responsive" style=" 
 
    margin: 0; 
 
"> 
 
     </a> 
 
     <br> 
 
     <span class="">On The Ground News Report</span> 
 
     </div> 
 
    </hgroup> 
 

 
    <div class="col-xs-6 col-sm-6 col-md-2 col-lg-2 masthead-group-2 text-right"> 
 
     <ul class="nav navbar-nav navbar-right"> 
 
     <!-- <li class="dropdown"> --> 
 
     <!-- <li> </li> --> 
 
     <!-- <li> </li> --> 
 
     <!-- </li> --> 
 
     <!-- <li> </li> --> 
 
     <!-- <li> </li> --> 
 

 
     <div class="dropdown"> 
 
      <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown"> 
 
      Login &amp; Join 
 
      <span class="caret"></span> 
 
      </button> 
 
      <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> 
 
      <li role="presentation"><a href="/login" role="menuitem" tabindex="-1"><i class="fa fa-sign-in"></i> Login</a> 
 
      </li> 
 
      <li role="presentation"><a href="/register" role="menuitem" tabindex="-1"><i class="fa fa-sign-out"></i> Join</a> 
 
      </li> 
 
      </ul> 
 
     </div> 
 
     </ul> 
 
    </div> 
 
    <!-- /dropdown-parent-div --> 
 

 
    <!-- /search-box-parent --> 
 

 

 
    <div class="hidden-sm hidden-xs col-md-4 col-lg-4 masthead-group-2"> 
 
     <div class="input-group"> 
 
     <div class="input-group-btn search-panel"> 
 
      <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 
 
      <span id="search_concept">Filter by</span> <span class="caret"></span> 
 
      </button> 
 
      <ul class="dropdown-menu" role="menu"> 
 
      <li><a href="#contains">Contains</a> 
 
      </li> 
 
      <li><a href="#its_equal">It's equal</a> 
 
      </li> 
 
      <li><a href="#greather_than">Greather than &gt;</a> 
 
      </li> 
 
      <li><a href="#less_than">Less than &lt; </a> 
 
      </li> 
 
      <li class="divider"></li> 
 
      <li><a href="#all">Anything</a> 
 
      </li> 
 
      </ul> 
 
     </div> 
 
     <input type="hidden" name="search_param" value="all" id="search_param"> 
 
     <input type="text" class="form-control" name="x" placeholder="Search term..."> 
 
     <span class="input-group-btn"> 
 
        <button class="btn btn-default" type="button"><span class="fa fa-search"></span> 
 
     </button> 
 
     </span> 
 
     </div> 
 
    </div> 
 
    <div class="hidden-sm hidden-xs col-md-3 col-lg-3 masthead-group-3"> 
 
     <!-- <div id="togglesidebar" class="btn btn-primary pull-right"> 
 
     <i class="fa fa-bars"></i> 
 
     </div> --> 
 

 
     <div id="togglesidebar" class="pull-right"> 
 
     <button class="btn btn-default btn-lg btn-primary"><i class="fa fa-child"></i> Submit News</button> 
 
     </div> 
 
    </div> 
 

 

 

 
    </div> 
 
    <div class="row clearfix"> 
 
    <div class="col-xs-12 col-sm-6 hidden-md hidden-lg masthead-group-2"> 
 
     <div class="input-group"> 
 
     <div class="input-group-btn search-panel"> 
 
      <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 
 
      <span id="search_concept">Filter by</span> <span class="caret"></span> 
 
      </button> 
 
      <ul class="dropdown-menu" role="menu"> 
 
      <li><a href="#contains">Contains</a> 
 
      </li> 
 
      <li><a href="#its_equal">It's equal</a> 
 
      </li> 
 
      <li><a href="#greather_than">Greather than &gt;</a> 
 
      </li> 
 
      <li><a href="#less_than">Less than &lt; </a> 
 
      </li> 
 
      <li class="divider"></li> 
 
      <li><a href="#all">Anything</a> 
 
      </li> 
 
      </ul> 
 
     </div> 
 
     <input type="hidden" name="search_param" value="all" id="search_param"> 
 
     <input type="text" class="form-control" name="x" placeholder="Search term..."> 
 
     <span class="input-group-btn"> 
 
        <button class="btn btn-default" type="button"><span class="fa fa-search"></span> 
 
     </button> 
 
     </span> 
 
     </div> 
 
    </div> 
 
    <div class="col-xs-12 col-sm-6 hidden-md hidden-lg masthead-group-3"> 
 
     <!-- <div id="togglesidebar" class="btn btn-primary pull-right"> 
 
     <i class="fa fa-bars"></i> 
 
     </div> --> 
 

 
     <div id="togglesidebar" class="pull-right"> 
 
     <button class="btn btn-default btn-lg btn-primary"><i class="fa fa-child"></i> Submit News</button> 
 
     </div> 
 
    </div> 
 
    </div> 
 
    <!-- /row --> 
 
</header>

+0

我嘗試了您的更改,並用結果更新了問題。幾乎在那裏,但仍有一些問題。思考? – marcamillion 2014-09-29 00:52:17

0

看看這個,按照該

http://getbootstrap.com/components/#navbar

你可以這樣做修改源代碼,以便更好地看看它在移動設備上。

<nav class="navbar navbar-default" role="navigation"> 
    <div class="container-fluid"> 
    <!-- Brand and toggle get grouped for better mobile display --> 
    <div class="navbar-header"> 
     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
     <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> 

    <!-- Collect the nav links, forms, and other content for toggling --> 
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
     <ul class="nav navbar-nav"> 
     <li class="active"><a href="#">Link</a></li> 
     <li><a href="#">Link</a></li> 
     <li class="dropdown"> 
      <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a> 
      <ul class="dropdown-menu" role="menu"> 
      <li><a href="#">Action</a></li> 
      <li><a href="#">Another action</a></li> 
      <li><a href="#">Something else here</a></li> 
      <li class="divider"></li> 
      <li><a href="#">Separated link</a></li> 
      <li class="divider"></li> 
      <li><a href="#">One more separated link</a></li> 
      </ul> 
     </li> 
     </ul> 
     <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> 
     </form> 
     <ul class="nav navbar-nav navbar-right"> 
     <li><a href="#">Link</a></li> 
     <li class="dropdown"> 
      <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a> 
      <ul class="dropdown-menu" role="menu"> 
      <li><a href="#">Action</a></li> 
      <li><a href="#">Another action</a></li> 
      <li><a href="#">Something else here</a></li> 
      <li class="divider"></li> 
      <li><a href="#">Separated link</a></li> 
      </ul> 
     </li> 
     </ul> 
    </div><!-- /.navbar-collapse --> 
    </div><!-- /.container-fluid --> 
</nav> 
+0

只是一個演示,#從getbootstrap.com複製# – shreyansh 2014-09-26 04:03:29

相關問題