2017-02-14 58 views
1

我想讓品牌在導航欄的中心,而我無法真正做到這一點。 我很樂意提供一些幫助。 感謝Bootstrap MVC如何將一個品牌居中

<div class="navbar navbar-inverse navbar-fixed-top" style="background-color:#f7e351; background-image:linear-gradient(#f7e351,#f7e351,#f7e351); border-color:#e7c02f;"> 
 
     <div class="container" style="background-color:#f7e351;"> 
 
      <div class="navbar-header" style="background-color:#f7e351;"> 
 
       <button type="button" style="background-color:#f7e351;" 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> 
 
       @Html.ActionLink("XXX", "Index", "XXX", new { area = "" }, new { @class = "navbar-brand" }) 
 
      </div> 
 
      @Html.ActionLink("Brand", "Brand", "Home", new { area = "" }, new { @class = "navbar-brand active" }) 
 
      <div class="navbar-collapse collapse"> 
 
       @Html.Partial("_LoginPartial2") 
 
      </div> 
 
     </div> 
 
    </div>

+0

要鏈接哪個鏈接?你有兩個類似「navbar-brand」的動作鏈接 –

+0

在動作鏈接中說「品牌」的動作鏈接 –

+0

已更新我的回答 –

回答

0

我創建了一個Bootply給你,讓你可以看到這個工作的可視化預期。

HTML:

<div class="navbar navbar-inverse navbar-fixed-top" style="background-color:#f7e351; background-image:linear-gradient(#f7e351,#f7e351,#f7e351); border-color:#e7c02f;"> 
    <div class="container" style="background-color:#f7e351;"> 
     <div class="navbar-header" style="background-color:#f7e351;"> 
      <button type="button" style="background-color:#f7e351;" 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">Center</a> 
     </div> 
     <a class="navbar-brand brand">Brand</a> 
    </div> 
</div> 

CSS:

.brand{ 
    position: absolute; 
    left: 48.5%; 
} 

詞重疊,因爲你不說出你的問題,其元素與navbar-brand類,你就想爲中心的,所以我做兩個都。

希望這會有所幫助。

+0

嘿!非常感謝你!即時通訊恐懼它沒有幫助,我可能有一個問題與我的代碼在一個不同的地方。 –

+0

@GilNave不客氣,請將此答案標記爲已接受,以便可以將此問題視爲已回答 –