bootstrap navbar-static-top menu breaks on two lines

后端 未结 2 1092
刺人心
刺人心 2021-02-12 10:52

I encountered a problem with the bootstrap navbar.

I Made menu using the navbar-static-top - at first it was all good. When menu was expanded and few items added, and no

相关标签:
2条回答
  • 2021-02-12 11:35

    I also wanted to use it through CSS without redownloading and customizing Bootstrap, Skelly answer is working fine on Bootstrap 3 but in my case Bootstrap 3.2 the CSS changed a litte... Here is an updated version of all CSS required

        @media (max-width:992px){
        .navbar-header {
            float: none;
        }
        .navbar-left,.navbar-right {
            float: none !important;
        }
        .navbar-toggle {
            display: block;
        }
        .navbar-collapse {
            border-top: 1px solid transparent;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
        }
        .navbar-fixed-top {
            top: 0;
            border-width: 0 0 1px;
         }
        .navbar-collapse.collapse {
            display: none!important;
        }
        .navbar-nav {
            float: none!important;
            margin-top: 7.5px;
         }
         .navbar-nav>li {
            float: none;
        }
        .navbar-nav>li>a {
            padding-top: 10px;
            padding-bottom: 10px;
        }
        .collapse.in{
            display:block !important;
        } 
    }
    
    0 讨论(0)
  • 2021-02-12 11:46

    You can have it collapse sooner using a CSS media query. The default breakpoint is 768px. Here we change it to 990 pixels so that it collapses before the 2-line wrapping starts..

    @media (max-width: 990px) {
        .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/119436

    0 讨论(0)
提交回复
热议问题