Multiple Collapse buttons in navbar with Bootstrap 3.0

前端 未结 1 1723
后悔当初
后悔当初 2021-02-19 10:07

I\'m using Bootstrap 3.0 to show a navbar with some links and a search field. When i go to \"mobile version\" i have a button that collapses the navbar and show all the content:

1条回答
  •  庸人自扰
    2021-02-19 10:32

    Separate the links and the search form into two navbar-collapse elements and have each button target the corresponding one:

    Sample markup:

    
    

    You would then just need to fix some conflicting styles between .navbar-nav and .navbar-collapse by adding this to your CSS:

    @media (max-width:767px) {
        .navbar-nav.navbar-collapse {
            margin-left: 0;
            margin-right: 0;
            padding-left: 0;
            padding-right: 0;
        }
    }
    

    Here's a demo fiddle

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