Twitter Bootstrap modal on mobile devices

前端 未结 12 2076
忘了有多久
忘了有多久 2020-12-02 04:20

Bootstrap modals don\'t work correctly on Android and iOS. The issue tracker acknowledges the problem but does not offer a working solution:

Modals in 2.0 are broke

12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 05:12

    We use this code to center the Bootstrap modal dialogs when they open. I haven't had any issue with them on iOS while using this but I'm not sure if it will work for Android.

    $('.modal').on('show', function(e) {
        var modal = $(this);
        modal.css('margin-top', (modal.outerHeight() / 2) * -1)
             .css('margin-left', (modal.outerWidth() / 2) * -1);
        return this;
    });
    

提交回复
热议问题