I am using Bootstrap v3.
I have the navbar classes in place so that when I have my screen mobile-size the navigation collapses and the little grid-like toggle button appears - so this is working as expected.
what i would like, is for this to be the default action for all screen sizes. That is, even on a desktop I would like the navigation to be collapsed and the toggle button to be visible.
I've had a look through the css and there is a whole bunch of stuff that provides the functionality, though I don't know which parts to change.
I've tried commenting out the larger media-queries, though there are a lot of them and it seems to have a knock-on effect to other styling.
any ideas?
To create a collapsible navigation bar, use a button with class="navbar-toggler", data-toggle="collapse" and data-target="#thetarget" . Then wrap the navbar content (links, etc) inside a div element with class="collapse navbar-collapse" , followed by an id that matches the data-target of the button: "thetarget".
For navbars that never collapse, add the . navbar-expand class on the navbar. For navbars that always collapse, don't add any .
Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles.
You can use override the default Bootstrap CSS like this...
.navbar-header { float: none; } .navbar-toggle { display: block; } .navbar-collapse { border-top: 1px solid transparent; box-shadow: inset 0 1px 0 rgba(255,255,255,0.1); } .navbar-collapse.collapse { display: none!important; } .navbar-nav { float: none!important; margin: 7.5px -15px; } .navbar-nav>li { float: none; } .navbar-nav>li>a { padding-top: 10px; padding-bottom: 10px; }
Demo: http://www.bootply.com/114896
This will ensure that the collapsed navbar is always used by overriding the Bootstrap @media queries.
Update: For Bootstrap 4, you just need to remove the navbar-toggleable
class: http://www.codeply.com/go/LN6szcJO53
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With