Solved

nav bar width

Posted on 2013-05-27
9
372 Views
Last Modified: 2013-05-31
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
Comment
Question by:jagguy
9 Comments
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
Comment Utility
0
 

Author Comment

by:jagguy
Comment Utility
I dont need to know how to do a menu but how in bootstrap to set the width before objects collapse/stack?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
do the width in percentage or vw and set min-width to 500px.

Cd&
0
 
LVL 9

Expert Comment

by:Ishaan Rawat
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:jagguy
Comment Utility
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
 
LVL 9

Expert Comment

by:Ishaan Rawat
Comment Utility
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
 

Author Comment

by:jagguy
Comment Utility
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
 
LVL 9

Accepted Solution

by:
Ishaan Rawat earned 500 total points
Comment Utility
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
 

Author Comment

by:jagguy
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now