• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

nav bar width

Hi,
In Twitter bootstrap this navbar collapses or stacks when browser resizes to under 979px.
How do I get it to collapse under a different size like 500px or any other width?


  <div class='navbar navbar-inverse'>
      <div class='navbar-inner nav-collapse' style="height: auto;">
        <ul class="nav">
          <li class="active"><a href="#">Home</a></li>
          <li><a href="#">Page One</a></li>
          <li><a href="#">Page Two</a></li>
        </ul>
      </div>
    </div> 

Open in new window

0
jagguy
Asked:
jagguy
1 Solution
 
jagguyAuthor Commented:
I dont need to know how to do a menu but how in bootstrap to set the width before objects collapse/stack?
0
 
COBOLdinosaurCommented:
do the width in percentage or vw and set min-width to 500px.

Cd&
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Ishaan RawatDesigner | Developer | ProgrammerCommented:
Try the following steps;;;

first locate the css where it is written  
@media (max-width: 979px)

Open in new window

in the bootstrap CSS....

Then make sure that it has ...only the navigation ids and classes... and one body tag....

If its true then modify the media query like the following....

@media (max-width: 500px) // Change that to your desired one.. 

Open in new window


If there's any problem contact us again... we'll be happy to help you...
0
 
jagguyAuthor Commented:
Ok i changed the media query and it works but there is so much other code I have changed as well that is the worry.

isnt it better I just add more css to override the specific css class/id instead of effecting everything else as there might be some unwanted side effects?

Placing my css file to override the boostrap css didnt work actually even when my css file is placed after the bootstrap css
bootstrap-responsive.css

/*@media (max-width: 979px) {    mychange*/
@media (max-width: 379px) { 
  body {
    padding-top: 0;
  }
  .navbar-fixed-top,
  .navbar-fixed-bottom {
    position: static;
  }
  .navbar-fixed-top {
    margin-bottom: 20px;
  }
  .navbar-fixed-bottom {
    margin-top: 20px;
  }
  .navbar-fixed-top .navbar-inner,
  .navbar-fixed-bottom .navbar-inner {
    padding: 5px;
  }
  .navbar .container {
    width: auto;
    padding: 0;
  }
  .navbar .brand {
    padding-right: 10px;
    padding-left: 10px;
    margin: 0 0 0 -5px;
  }
  .nav-collapse {
    clear: both;
  }
  .nav-collapse .nav {
    float: none;
    margin: 0 0 10px;
  }
  .nav-collapse .nav > li {
    float: none;
  }
  .nav-collapse .nav > li > a {
    margin-bottom: 2px;
  }
  .nav-collapse .nav > .divider-vertical {
    display: none;
  }
  .nav-collapse .nav .nav-header {
    color: #777777;
    text-shadow: none;
  }
  .nav-collapse .nav > li > a,
  .nav-collapse .dropdown-menu a {
    padding: 9px 15px;
    font-weight: bold;
    color: #777777;
    -webkit-border-radius: 3px;
       -moz-border-radius: 3px;
            border-radius: 3px;
  }
  .nav-collapse .btn {
    padding: 4px 10px 4px;
    font-weight: normal;
    -webkit-border-radius: 4px;
       -moz-border-radius: 4px;
            border-radius: 4px;
  }
  .nav-collapse .dropdown-menu li + li a {
    margin-bottom: 2px;
  }
  .nav-collapse .nav > li > a:hover,
  .nav-collapse .nav > li > a:focus,
  .nav-collapse .dropdown-menu a:hover,
  .nav-collapse .dropdown-menu a:focus {
    background-color: #f2f2f2;
  }
  .navbar-inverse .nav-collapse .nav > li > a,
  .navbar-inverse .nav-collapse .dropdown-menu a {
    color: #999999;
  }
  .navbar-inverse .nav-collapse .nav > li > a:hover,
  .navbar-inverse .nav-collapse .nav > li > a:focus,
  .navbar-inverse .nav-collapse .dropdown-menu a:hover,
  .navbar-inverse .nav-collapse .dropdown-menu a:focus {
    background-color: #111111;
  }
  .nav-collapse.in .btn-group {
    padding: 0;
    margin-top: 5px;
  }
  .nav-collapse .dropdown-menu {
    position: static;
    top: auto;
    left: auto;
    display: none;
    float: none;
    max-width: none;
    padding: 0;
    margin: 0 15px;
    background-color: transparent;
    border: none;
    -webkit-border-radius: 0;
       -moz-border-radius: 0;
            border-radius: 0;
    -webkit-box-shadow: none;
       -moz-box-shadow: none;
            box-shadow: none;
  }
  .nav-collapse .open > .dropdown-menu {
    display: block;
  }
  .nav-collapse .dropdown-menu:before,
  .nav-collapse .dropdown-menu:after {
    display: none;
  }
  .nav-collapse .dropdown-menu .divider {
    display: none;
  }
  .nav-collapse .nav > li > .dropdown-menu:before,
  .nav-collapse .nav > li > .dropdown-menu:after {
    display: none;
  }
  .nav-collapse .navbar-form,
  .nav-collapse .navbar-search {
    float: none;
    padding: 10px 15px;
    margin: 10px 0;
    border-top: 1px solid #f2f2f2;
    border-bottom: 1px solid #f2f2f2;
    -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
       -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
  }
  .navbar-inverse .nav-collapse .navbar-form,
  .navbar-inverse .nav-collapse .navbar-search {
    border-top-color: #111111;
    border-bottom-color: #111111;
  }
  .navbar .nav-collapse .nav.pull-right {
    float: none;
    margin-left: 0;
  }
  .nav-collapse,
  .nav-collapse.collapse {
    height: 0;
    overflow: hidden;
  }
  .navbar .btn-navbar {
    display: block;
  }
  .navbar-static .navbar-inner {
    padding-right: 10px;
    padding-left: 10px;
  }
}

@media (min-width: 980px) {
  .nav-collapse.collapse {
    height: auto !important;
    overflow: visible !important;
  }
}

Open in new window

0
 
Ishaan RawatDesigner | Developer | ProgrammerCommented:
There is a solution for this....

Just add !important to every single style of your code... That you have provided..

Wait I have done that for you...

@media (max-width: 379px) { 
  body {
    padding-top: 0 !important;
  }
  .navbar-fixed-top,
  .navbar-fixed-bottom {
    position: static !important;
  }
  .navbar-fixed-top {
    margin-bottom: 20px !important;
  }
  .navbar-fixed-bottom {
    margin-top: 20px !important;
  }
  .navbar-fixed-top .navbar-inner,
  .navbar-fixed-bottom .navbar-inner {
    padding: 5px !important;
  }
  .navbar .container {
    width: auto !important;
    padding: 0 !important;
  }
  .navbar .brand {
    padding-right: 10px !important;
    padding-left: 10px !important;
    margin: 0 0 0 -5px !important;
  }
  .nav-collapse {
    clear: both !important;
  }
  .nav-collapse .nav {
    float: none !important;
    margin: 0 0 10px !important;
  }
  .nav-collapse .nav > li {
    float: none !important;
  }
  .nav-collapse .nav > li > a {
    margin-bottom: 2px !important;
  }
  .nav-collapse .nav > .divider-vertical {
    display: none !important;
  }
  .nav-collapse .nav .nav-header {
    color: #777777 !important;
    text-shadow: none !important;
  }
  .nav-collapse .nav > li > a,
  .nav-collapse .dropdown-menu a {
    padding: 9px 15px !important;
    font-weight: bold !important;
    color: #777777 !important;
    -webkit-border-radius: 3px !important;
       -moz-border-radius: 3px !important;
            border-radius: 3px !important;
  }
  .nav-collapse .btn {
    padding: 4px 10px 4px !important;
    font-weight: normal !important;
    -webkit-border-radius: 4px !important;
       -moz-border-radius: 4px !important;
            border-radius: 4px !important;
  }
  .nav-collapse .dropdown-menu li + li a {
    margin-bottom: 2px !important;
  }
  .nav-collapse .nav > li > a:hover,
  .nav-collapse .nav > li > a:focus,
  .nav-collapse .dropdown-menu a:hover,
  .nav-collapse .dropdown-menu a:focus {
    background-color: #f2f2f2 !important;
  }
  .navbar-inverse .nav-collapse .nav > li > a,
  .navbar-inverse .nav-collapse .dropdown-menu a {
    color: #999999 !important;
  }
  .navbar-inverse .nav-collapse .nav > li > a:hover,
  .navbar-inverse .nav-collapse .nav > li > a:focus,
  .navbar-inverse .nav-collapse .dropdown-menu a:hover,
  .navbar-inverse .nav-collapse .dropdown-menu a:focus {
    background-color: #111111 !important;
  }
  .nav-collapse.in .btn-group {
    padding: 0 !important;
    margin-top: 5px !important;
  }
  .nav-collapse .dropdown-menu {
    position: static !important;
    top: auto !important;
    left: auto !important;
    display: none !important;
    float: none !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 15px !important;
    background-color: transparent !important;
    border: none !important;
    -webkit-border-radius: 0 !important;
       -moz-border-radius: 0 !important;
            border-radius: 0 !important;
    -webkit-box-shadow: none !important;
       -moz-box-shadow: none !important;
            box-shadow: none !important;
  }
  .nav-collapse .open > .dropdown-menu {
    display: block !important;
  }
  .nav-collapse .dropdown-menu:before,
  .nav-collapse .dropdown-menu:after {
    display: none !important;
  }
  .nav-collapse .dropdown-menu .divider {
    display: none !important;
  }
  .nav-collapse .nav > li > .dropdown-menu:before,
  .nav-collapse .nav > li > .dropdown-menu:after {
    display: none !important;
  }
  .nav-collapse .navbar-form,
  .nav-collapse .navbar-search {
    float: none !important;
    padding: 10px 15px !important;
    margin: 10px 0 !important;
    border-top: 1px solid #f2f2f2 !important;
    border-bottom: 1px solid #f2f2f2 !important;
    -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1) !important;
       -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1) !important;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  }
  .navbar-inverse .nav-collapse .navbar-form,
  .navbar-inverse .nav-collapse .navbar-search {
    border-top-color: #111111 !important;
    border-bottom-color: #111111 !important;
  }
  .navbar .nav-collapse .nav.pull-right {
    float: none !important;
    margin-left: 0 !important;
  }
  .nav-collapse,
  .nav-collapse.collapse {
    height: 0 !important;
    overflow: hidden !important;
  }
  .navbar .btn-navbar {
    display: block !important;
  }
  .navbar-static .navbar-inner {
    padding-right: 10px !important;
    padding-left: 10px !important;
  }
}

Open in new window


and just make sure to remove the above code from the
@media (max-width: 979px)

Open in new window



This will surely work,,,
0
 
jagguyAuthor Commented:
no this doesnt work sorry.

if I have your code in a css file it doesnt override the bootstrap css as I just tied it. Anyway I am after a conventional solution so maybe I just need to alter bootstrap css and leave it as that.

if I have a problem then I can custom make a navigation my self and avoid navbar classes
0
 
Ishaan RawatDesigner | Developer | ProgrammerCommented:
Let me again tell you the steps...


First locate the navbar files in the bootstrap-responsive.css under the media queries... then cut them and paste then in the end of the bootstrap-responsive.css under the head
@media (max-width: 379px)

Open in new window

... If possible please give me a live url of the page...
0
 
jagguyAuthor Commented:
yes it works in the same file as you suggest.
it doesnt work when I place the same code in my own css and leave the orginal.
no matter as I dont intend to use the nav bar anyway.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now