Bootstrap Navbar width same as container

后端 未结 3 1588
清歌不尽
清歌不尽 2021-01-14 03:06

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 si

相关标签:
3条回答
  • 2021-01-14 03:25

    Just turn the class container-fluid to container, and you're done. Worked for me...

    0 讨论(0)
  • 2021-01-14 03:30

    you forgot a row class (line 2)

    <nav class="navbar navbar-default navbar-inverse navbar-fixed-top container" role="navigation">
      <div class="row">
        <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="#">title</a>
              </li>
              <li><a href="#">title</a>
              </li>
              <li><a href="#">title</a>
              </li>
              <li><a href="#">title</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </nav>

    0 讨论(0)
  • 2021-01-14 03:46

    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.

    0 讨论(0)
提交回复
热议问题