Bootstrap dropdown sub menu missing

后端 未结 7 1211
再見小時候
再見小時候 2020-11-22 04:09

Bootstrap 3 is still at RC, but I was just trying to implement it. I couldn\'t figure out how to put a sub menu class. Even there is no class in css and even the new docs do

7条回答
  •  眼角桃花
    2020-11-22 04:39

    @skelly solution is good but will not work on mobile devices as the hover state won't work.

    I have added a little bit of JS to get the BS 2.3.2 behavior back.

    PS: it will work with the CSS you get there: http://bootply.com/71520 though you can comment the following part:

    CSS:

    /*.dropdown-submenu:hover>.dropdown-menu{display:block;}*/
    

    JS:

    $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) {
      // Avoid following the href location when clicking
      event.preventDefault();
      // Avoid having the menu to close when clicking
      event.stopPropagation();
      // If a menu is already open we close it
      $('ul.dropdown-menu [data-toggle=dropdown]').parent().removeClass('open');
      // opening the one you clicked on
      $(this).parent().addClass('open');
    });
    

    The result can be found on my WordPress theme (Top of the page): http://shprinkone.julienrenaux.fr/

提交回复
热议问题