0

How to change navbar/container width? Bootstrap 3 While following this I am super confused. I am still fairly new in CSS, so I am still playing around a lot with bootstrap.

I added a div right outside of the navbar div to contain the total width.

.navbar-outer {
  width:1000px;
  margin-left: auto;
  margin-right: auto;
}

That worked well, but as soon as I narrow the browser. The "Mobile" button no longer shows. Any suggestion on changes while keeping everything intact in the css? This is for bootstrap 3.3.4.

Full code below:

  <nav class="navbar navbar-default">
    <div class="navbar-outer">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Brand</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> Action <span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Separated link</a></li>
                <li class="divider"></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
              <form class="navbar-form navbar-left" role="search">
                <div class="form-group">
                  <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
              </form>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><img src="testimage.jpg" style="width: 25px; height: 25px;" alt="..." class="img-circle"> Me <span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Separated link</a></li>
              </ul>
            </li>
          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
      </div>
    </nav>
Community
  • 1
  • 1
user4713659
  • 25
  • 1
  • 6

1 Answers1

0

I think it might be that you are setting the width with px, meaning the collapsing feature of the Bootstrap navbar cannot be triggered. I believe it collapses at 768px.

Using min-width and max-width:

.navbar-outer {
  max-width:1000px;
  min-width:767px;
  margin-left: auto;
  margin-right: auto;
}

http://jsfiddle.net/frank184/m3n3r1tg/

fbelanger
  • 3,522
  • 1
  • 17
  • 32
  • Any way to retain navbar width and along with the collapses? – user4713659 May 08 '15 at 21:49
  • Setting max-width and min-width perhaps? – fbelanger May 08 '15 at 21:50
  • gonna be scratching my head for a while on this one :P – user4713659 May 08 '15 at 21:52
  • Oh snap, that kinda worked.. but when i keep dragging it smaller. the button doesn't follow the screen. Actually, you resolved it. I put the min-width even lower, and it works like a charm! Thanks man! – user4713659 May 08 '15 at 22:09
  • No problem, just as a side note and something to keep in mind carrying on with Bootstrap, it's suppose to be a responsive framework. Try to let it do it's thing and not set widths using pixels. tbh, this is probably the best solution to your problem .navbar-outer { } – fbelanger May 08 '15 at 22:17