简体   繁体   English

将Bootstrap导航栏切成两半

[英]Cut Bootstrap navbar in half

I'm using Bootstrap navbar with the bootstrap.min.css file. 我正在使用带有bootstrap.min.css文件的Bootstrap导航栏。 This navbar stretches to the entire screen, where in the CSS file do I change the navbar settings (I don't want it to stretch)? 这个导航栏延伸到整个屏幕,我在CSS文件中更改导航栏设置(我不希望它拉伸)? There are a lot of navbar classes there and I can't seem to locate the right one. 那里有很多navbar类,我似乎无法找到合适的类。

<div class="navbar navbar-inverse navbar-static-top">
        <div class="container">

            <a href="#" class="navbar-brand">Imperia Bank</a>

            <button class="navbar-toggle" data-toggle="collapse"
                data-target=".navHeaderCollapse">
                <span class="icon-bar"></span> <span class="icon-bar"></span> <span
                    class="icon-bar"></span>
            </button>

            <div class="collapse navbar-collapse navHeaderCollapse">

                <ul class="nav navbar-nav navbar-right">

                    <li class="active"><a href="homepage.html">Home</a></li>
                    <li><a href="Login.html">Login</a></li>
                    <li><a href="Register.html">Register</a></li>
                    <li><a href="customer.html">Clients</a></li>
                    <li><a href="Administrator.html">Administrator</a></li>
                    <li><a href="account.html">Accounts</a></li>
                    <li><a href="Illustration.html">Illustration</a></li>
                    <li ><a href="ATM.html">Atm</a></li>

                </ul>

            </div>

        </div>
    </div>

<div class="container">放在<div class="navbar navbar-inverse navbar-static-top">

For anyone trying to make the navbar a custom width in Bootstrap 4, just override the navbar css width. 对于试图在导航4中使导航栏成为自定义宽度的任何人,只需覆盖导航栏的CSS宽度即可。

For example: 例如:

.navbar {
   width: 400px;
} 

In case you have more than 1 navbars (?!) just specify a custom class/id for the one you want to alter. 如果您有多个导航栏(?!),只需为要更改的导航栏指定自定义类/ ID。

You should be able add your own styles on top of the existing styles. 您应该可以在现有样式之上添加自己的样式。 Using a tool like the chrome debugger you should b able to find the style rule that is doing this and then in your own stylesheet just use a more specific CSS selector to override it. 使用像chrome调试器这样的工具,您应该能够找到执行此操作的样式规则,然后在您自己的样式表中使用更具体的CSS选择器来覆盖它。

You can place the navbar in its own container (with applicable ID) and adjust the width of the container in your stylesheets. 您可以将导航栏放在其自己的容器中(具有适用的ID),并在样式表中调整容器的宽度。 As Swagata said, you should be able to just flip the div tags and adjust your css accordingly. 正如Swagata所说,你应该只需翻转div标签并相应地调整你的css。 I'd give it a memorable name, though, for the sake of editing. 不过,为了编辑,我会给它一个令人难忘的名字。

There is no pretty way to do this, considering .navbar was built to span the screen. 考虑到.navbar是为了跨越屏幕而构建的,没有很好的方法可以做到这一点。 But it can be accomplished fairly easily using the built in grid. 但是使用内置网格可以很容易地完成它。

<div id='row'>
    <div id='col-md-6'>
        INSERT NAVBAR HERE
    </div>
    <div id='col-md-6'>
        INSERT WHATEVER YOU WANT ON THE OTHER HALF OF THE SCREEN HERE
    </div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM