Bootstrap 4 navigation, left-side toggle with righ

2019-06-08 18:53发布

I'm trying to have a collapsible bootstrap 4 navigation with the toggle button on the left-hand side. This isn't a problem, but I'm also trying to have an action button (or buttons) on the right side of the navigation.

How can I have buttons/links on the right-hand side that are excluded from the navbar-collapse menu. Additionally, how can I avoid the navbar-collapse menu pushing down these items when expanded? I can float the right button but this also causes issues.

Refer to the image:

enter image description here

Live Codeply example of current implementation: https://www.codeply.com/go/IDCOYUVXCH

1条回答
我命由我不由天
2楼-- · 2019-06-08 19:20

You would have to use the flexbox utils like this...

https://www.codeply.com/go/xXGsq5MVdi

<nav class="navbar navbar-fixed-top navbar-toggleable-sm navbar-inverse bg-inverse">
    <div class="container d-flex flex-row flex-md-nowrap flex-wrap">
    <a href="#" class="hidden-lg-up my-2 mr-3" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false">
        <i class="fa fa-bars text-white"></i>
    </a>
    <a class="navbar-brand" href="#">Brand</a>
    <div class="navbar-collapse collapse flex-md-unordered flex-last" id="navbarCollapse">
        <ul class="navbar-nav">
            <li class="nav-item active">
                <a class="nav-link" href="#">Link <span class="sr-only">Home</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
        </ul>
    </div>
    <div class="d-flex ml-auto">
         <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="#">Right</a>
            </li>
        </ul>
    </div>
    <div class="hidden-md-up w-100"><!--hidden spacer to force wrap--></div>
    </div>
</nav>

https://www.codeply.com/go/xXGsq5MVdi

查看更多
登录 后发表回答