Bootstrap dropdown clipped by overflow:hidden container, how to change the container?

后端 未结 16 1777
孤城傲影
孤城傲影 2020-12-02 18:07

Using bootstrap, I have a dropdown menu(s) inside a div with overflow:hidden, which is needed to be like this. This caused the dro

16条回答
  •  Happy的楠姐
    2020-12-02 19:00

    All the answers mentioned here didn't work for me, so I found another workaround:

    $('.dropdown').on('shown.bs.dropdown', function () {
        const dropdown = $(this);
        setTimeout(function () {
            dropdown.find('.dropdown-menu').css({'top': dropdown.offset().top - $(window).scrollTop(), 'left': dropdown.offset().left - $(window).scrollLeft(), 'position': 'fixed'});
        }, 1);
    });
    

    The timeout is necessary as the event handler is fired before bootstraps sets the CSS of the dropdown therefore overwriting it

提交回复
热议问题