Bootstrap崩溃得太快了

时间:2016-12-16 17:54:03

标签: html css twitter-bootstrap navbar

My Bootstrap导航栏分为2行,但还剩下一些空格:

enter image description here

在导航栏中,我还有navbar-right:

        <ul class="nav navbar-nav">
            <li class="active"><a class="txt-c" href="/home/"><p><i class="fa fa-bandcamp"></i></p>Home</a></li>
            <li class=""><a href="/sample/"><p><i class="fa fa-codepen"></i></p>Demo</a></li>
            <li class=""><a href="/sample/"><p><i class="fa fa-file-text"></i></p>Notice</a></li>
            <li class=""><a class="txt-c" href="/contact/"><p><i class="fa fa-envelope-open"></i></p>Contact</a></li>
            <li class=""><a href="/sample/"><p><i class="fa fa-shopping-cart"></i></p>Purchase</a></li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
            <li class=""><a class="nav-signin" href="/signin">Log in</a></li>
            <li class=""><a class="nav-signup" href="/signup">Sign up</a></li>
            <li class="dropdown">
                <a href="#/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">EN<span class="caret"></span></a>
                <ul class="dropdown-menu">
                    <li><a class="nav-lang" href="?lang=fr"><span class="pad-l-10 fnt-rob pad-t-10">Français</span></a></li>

                </ul>
            </li>
        </ul>

如何在折叠前使导航栏和导航栏最靠近?

2 个答案:

答案 0 :(得分:2)

您可以编写新的媒体规则或重写Bootstrap断点

我试图重现你的问题

<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li><a href="index.php">Home</a></li>
                <li><a href="about.php">About</a></li>
                <li><a href="#portfolio">Portfolio</a></li>
                <li><a href="#">Blog</a></li>
                <li><a href="contact.php">Contact</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li class=""><a class="nav-signin" href="/signin">Log in</a></li>
                <li class=""><a class="nav-signup" href="/signup">Sign up</a></li>
                <li class="dropdown">
                    <a href="#/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">EN<span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a class="nav-lang" href="?lang=fr"><span class="pad-l-10 fnt-rob pad-t-10">Français</span></a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

示例css:

@media (min-width: 550 px) {
    .navbar-nav > li {
        float: left;
    }
    .navbar-right {
        float: right!important;
        margin-right: -15 px;
    }
    .nav {
        display: inline-block;
    }
    .navbar-collapse.collapse {
        display: block;
    }
    .navbar-header {
        display: none;
    }
    .navbar .navbar-nav .open .dropdown-menu {
        position: absolute;
        right: 0;
        left: auto;
        display: block;
        background: #000000;
    }
}

我尝试保存示例http://www.bootply.com/MvKdHiXkyW#

答案 1 :(得分:1)

如果我理解你的问题很简单,只需从引导程序覆盖.navbar-right规则即可。在我的示例中,我插入了margin-right:150px;

https://jsfiddle.net/f7pw4ouk/