Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Navbar width same as container

I am using Bootstrap 3 . i can't give the navbar same width with the container. if it works in large screen but don't work in other screen size. How can i make a fixed size of my navbar which will change different screen with the same width as container has.

<div class="row"><!--Start row-->
     <nav class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation">
         <div class="container">
                <div class="navbar-header"><!-- -->
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="glyphicon glyphicon-arrow-down">Menu</span>
                    </button>

                </div>
                <div class="collapse navbar-collapse" id="collapse">
                    <ul class="nav navbar-nav">
                        <li><a href="#">Home</a></li>
                        <li><a href="#">About</a></li>
                        <li><a href="#">Course List</a></li>
                        <li><a href="#">Contact Us</a></li>
                    </ul>
                </div><!--End Collapse-->
         </div>
     </nav><!--End Navbar-->
</div>
like image 905
Nazmul Avatar asked Nov 30 '22 02:11

Nazmul


1 Answers

The fix I would make to this is to simply put the container class in the <nav class="..."> this will constrain your nave bar to be the width specified by the container attribute.

Code below:

<nav class="navbar navbar-default navbar-inverse navbar-fixed-top container" role="navigation">
         <div class="container-fluid">
                <div class="navbar-header"><!-- -->
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="glyphicon glyphicon-arrow-down">Menu</span>
                    </button>

                </div>
                <div class="collapse navbar-collapse" id="collapse">
                    <ul class="nav navbar-nav">
                        <li><a href="#">Home</a></li>
                        <li><a href="#">About</a></li>
                        <li><a href="#">Course List</a></li>
                        <li><a href="#">Contact Us</a></li>
                    </ul>
                </div><!--End Collapse-->
         </div>
     </nav>

Also it is not nessicary for the <nav> to be wrapped in a <div class="row"> I hope this is what you were looking for.

like image 58
theRyanMark Avatar answered Dec 04 '22 00:12

theRyanMark