Twitter Bootstrap Accordion and button dropdown overflow issue

前端 未结 10 1764
一个人的身影
一个人的身影 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 13:03

    I don't know if you would find this an acceptable alternative solution, or how many items your dropdown would have, but you could use the "dropup" class, so as to make the dropdown menu drop UP instead of down.

    http://jsfiddle.net/ecSH4/


    UPDATE

    Rather kludgy at this point, yet in a limited sense, it "works".

    http://jsfiddle.net/ecSH4/52/

    $(".special-drop, .special-drop .caret").click(function() {
        var $myCollapsable = $(this).closest(".collapse"),
            $myDropDown = $(this).closest(".dropdown"),
            $myDropDownMenu = $(this).next(".dropdown-menu");
    
        function toggleDropMenu() {
            if ($myDropDown.hasClass("open")) {
                $myDropDownMenu.hide();
            } else {
                $myDropDownMenu.show();
            }
        }
    
        if ($myCollapsable.css("overflow") === "hidden") {
            $myCollapsable.css("overflow", "visible");
            toggleDropMenu();
        } else {
            $myCollapsable.css("overflow", "hidden");
            $myDropDownMenu.hide();
            toggleDropMenu();
        }
    
    });
    
    $(document).click(function() {
       $(".collapse").css("overflow", "hidden");
       $(".dropdown-menu").hide();
    });​
    

提交回复
热议问题