Search code examples
twitter-bootstraptwitter-bootstrap-3navbar

Bootstrap 3 Navbar Collapse


Is there any way to increase the point at which the bootstrap 3 navbar collapses (i.e. so that it collapses into a drop down on portrait tablets)?

These two were applicable to bootstrap 2 but not now!

How to change navbar collapse threshold using Twitter bootstrap-responsive?

Change the default responsive navbar breakpoint


Solution

  • I had the same problem today.

    Bootstrap 4

    It's a native functionality: https://getbootstrap.com/docs/4.0/components/navbar/#responsive-behaviors

    You have to use .navbar-expand{-sm|-md|-lg|-xl} classes:

    <nav class="navbar navbar-expand-md navbar-light bg-light">
    

    Bootstrap 3

    @media (max-width: 991px) {
        .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;
        }
        .navbar-text {
            float: none;
            margin: 15px 0;
        }
        /* since 3.1.0 */
        .navbar-collapse.collapse.in { 
            display: block!important;
        }
        .collapsing {
            overflow: hidden!important;
        }
    }
    

    Just change 991px by 1199px for md sizes.

    Demo