Twitter Bootstrap Accordion and button dropdown overflow issue

前端 未结 10 1750
一个人的身影
一个人的身影 2021-02-12 12:25

I\'m using Bootstrap for a section of my website. I mix accordion with a dropdown button. The problem comes when the button is on the bottom, the drop-down is hidden since the .

10条回答
  •  借酒劲吻你
    2021-02-12 12:59

    Set overflow: visible when the menu is open (demo):

    $('html').on('click', function() {
        setTimeout(function() {
            $('[data-toggle="dropdown"]').closest('.collapse').css('overflow', '');
        }, 0);
    });
    
    $('body').on('click', '[data-toggle="dropdown"]', function() {
        var parent = $(this).parent(), collapse = parent.closest('.collapse');
        setTimeout(function() {
            collapse.css('overflow', parent.hasClass('open') ? 'visible' : '');
        }, 0);
    });
    

    There seems to be a redraw issue in Chrome (tested with Chrome 19 on Linux) if we set overflow directly. setTimeout() works around this issue.

提交回复
热议问题