Navbar not collapsing with Bootstrap

前端 未结 6 952
旧时难觅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

    1. You will need to have the compiled version of bootstrap.js or bootstrap.min.js with collapse and transition checked[and therefore included] for compilation.
    2. Give your parent div an id. If it already has one, take note of it. Your parent div is going to be the one whose immediate children comprise the dropdown [the links, buttons, etc.]
    3. Add data-toggle and data-target to each of the child elements of our previously talked-about parent div.
      Assuming the parent div's is id="my_parent_div", the child elements should each have data-toggle="collapse" data-target="#my_parent_div" appended inside the link attribute.

    Here's a sample from my fixed navbar code:

    
    

    Hope this helps :)

提交回复
热议问题