Rainieren
1 year ago
896
1
Laravel

Bootstrap 4 - Fixed navbar full width collumn

Posted 1 year ago by Rainieren

Hello, I'm making a dashboard and I want to have a fixed navbar in bootstrap that is the full width of my column which is col-md-10 But when I add position: fixed; to the navbar the navbar stretches 100% across the whole page instead of staying in the column. How can I solve this? Here is an image of what I am trying to achieve: https://imgur.com/a/xp4mC The navbar needs to be the full width of the blue column. In the picture it is but it does not have position: fixed;, If I add that, however. It will look like this.: https://imgur.com/a/GYdYQ

Here is the code:

<div class="container" style="max-width: 100%; margin: 0;">
    <div class="row">
        <div class="col-md-2" style="background-color: red; height: 100px;">



        </div>
        <div class="col-md-10" style="background-color: blue; height: 100px; padding: 0;">

            <nav class="navbar navbar-expand-lg navbar-light z-depth-3 border-none" style="background-color: #ffffff; padding-top: 12px; padding-bottom: 12px;">
                <div class="container-fluid" style="padding-left: 0;">
                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <a class="navbar-brand" href="#">Navbar</a>
                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                        <ul class="navbar-nav mr-auto">
                            <li class="nav-item">
                            </li>
                        </ul>

                        <ul class="navbar-nav">
                            <li class="nav-item">
                                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    <span class="hidden-xs-only">John Doe</span>
                                </a>
                                <div class="dropdown-menu pull-right" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" href="#">Action</a>
                                    <a class="dropdown-item" href="#">Another action</a>
                                    <a class="dropdown-item" href="#">Something else here</a>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>

        </div>
    </div>
</div>

How can I solve this?

Thanks in advance

Please sign in or create an account to participate in this conversation.