Force Bootstrap dropdown menu to always display at the bottom and allow it go offscreen

前端 未结 3 670
谎友^
谎友^ 2021-02-07 02:38

When there is no room at the bottom of the viewport to fit dropdown menu, it is displayed at the top of its dropdown button. Is it possible alter this behavior and make dropdown

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-07 02:46

    Bootstrap 4 uses Popper.js for positioning the dropdowns. Additionally, Bootstrap 4 allows you to pass some data-* attributes to control the behaviour of Popper.js on that dropdown.

    The option that needs to be tweaked is the flip option of Popper.js. By default Bootstrap 4 sets this to true, causing dropdowns to appear above the dropdown-toggle element when there is not enough room at the bottom of the viewport.

    To force the dropdown to always appear at the bottom, add data-flip="false" as an attribute of your dropdown-toggle element. For example:

提交回复
热议问题