Twitter Bootstrap 3.0.3 Navbar对齐Navbar标题

时间:2014-01-20 11:13:39

标签: css3 twitter-bootstrap twitter-bootstrap-3 navbar

我很难将导航栏品牌标识居中。

目前,我的徽标将与左侧对齐。

我想要实际上将它与第一个链接对齐。请在下面找到样本: enter image description here

请在JSFiddle

下面找到我的代码

http://jsfiddle.net/QSa8v/3/

<div id="navbar">
    <nav role="navigation" class="navbar-custom">
        <div class="navbar-header">
            <button data-toggle="collapse" data-target="#ren-nav-collapse" class="navbar-toggle">
                <span class="sr-only">
                    Toggle navigation
                </span>
                <span class="icon-bar" />
                <span class="icon-bar" />
                <span class="icon-bar" />
            </button>
            <a href="#" class="navbar-brand">
                <img src="http://i.imgur.com/CMEnIo7.png" />
            </a>
        </div>
        <div class="collapse navbar-collapse" id="ren-nav-collapse">
            <ul class="nav navbar-nav">
                <li>
                    <a href="#">LINK 1</a>
                </li>
                <li>
                    <a href="#">LINK 2</a>
                </li>
                <li>
                    <a href="#">LINK 3</a>
                </li>
                <li>
                    <a href="#">LINK 4</a>
                </li>
                <li>
                    <a href="#">LINK 5</a>
                </li>
                <li>
                    <a href="#">LINK 6</a>
                </li>
            </ul>
        </div>
    </nav>
</div>

真的需要你的回答。

1 个答案:

答案 0 :(得分:2)

请看这里:http://jsfiddle.net/QSa8v/4/

HTML更改:

<div id="navbar">
    <nav role="navigation" class="navbar-custom">
        <div class="navbar-header col-xs-3 myheader">    // CHANGE HERE
            <button data-toggle="collapse" data-target="#ren-nav-collapse" class="navbar-toggle">
                <span class="sr-only">
                    Toggle navigation
                </span>
                <span class="icon-bar" />
                <span class="icon-bar" />
                <span class="icon-bar" />
            </button>
            <a href="#" class="navbar-brand mybrand">     // CHANGE HERE
                <img src="http://i.imgur.com/CMEnIo7.png" />
            </a>
        </div>
        <div class="collapse navbar-collapse" id="ren-nav-collapse">
            <ul class="nav navbar-nav mybar">          // CHANGE HERE
                <li>
                    <a href="#">LINK 1</a>
                </li>
                <li>
                    <a href="#">LINK 2</a>
                </li>
                <li>
                    <a href="#">LINK 3</a>
                </li>
                <li>
                    <a href="#">LINK 4</a>
                </li>
                <li>
                    <a href="#">LINK 5</a>
                </li>
                <li>
                    <a href="#">LINK 6</a>
                </li>
            </ul>
        </div>
    </nav>
</div>

CSS添加:

.mybar {
    margin-left:0px !important;
}
.mybrand{
     float:none !important;   
}

.myheader{
    text-align: center;
    padding: 1em;
}