Navbar not collapsing with Bootstrap

前端 未结 6 944
旧时难觅i
旧时难觅i 2021-02-06 13:26

I have a website that is made with Twitter Bootstrap. On a large screen the navbar is looking nice as it should be but if you see the same navbar on a cellphone the navbar won\'

6条回答
  •  日久生厌
    2021-02-06 14:03

    Yes follow the instructions from Betty St (include responsive css, bootstrap-collapse.js and the Transitions plugin update: (bootstrap-transition.js) and jQuery). You need to add a button / link which triggers the collapse. This tags get the attributes: data-toggle="collapse" data-target=".nav-collapse" where data-target can be any css selector. Put your nav between the tag selected under data-target, see: http://bootply.com/62921

    html:

    
    

    update Your code is missing the Transitions plugin (bootstrap-transition.js) required by the Collapse plugin. More important you didn't include jQuery. Now it should work see: http://plnkr.co/l66QqCftGNsaG0xkBrUf

    javascript includes:

       
    
    
    

    Note: Consider to include the compiled (or minified) version of the complete javascripts:

      
    

    You also need to change the style after collapsing:

    .navbar .in .nav li {
       display: block;
       float: none;
       width:100%;
    }
    

提交回复
热议问题