Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

nav bar width

Posted on 2013-05-27
9
Medium Priority
?
391 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Author Comment

by:jagguy
ID: 39199194
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
ID: 39199444
do the width in percentage or vw and set min-width to 500px.

Cd&
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:Ishaan Rawat
ID: 39199498
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
 

Author Comment

by:jagguy
ID: 39199938
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 10

Expert Comment

by:Ishaan Rawat
ID: 39200306
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
ID: 39200928
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 10

Accepted Solution

by:
Ishaan Rawat earned 2000 total points
ID: 39200947
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
ID: 39210466
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

636 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