Bootstrap modal on hiding adds padding-right to html body

前端 未结 2 472
离开以前
离开以前 2020-12-22 05:24

I am hiding and showing modal in this sequence:

when I click on import button it will target modal with id=\"import-actionpopup\" then I have two other

2条回答
  •  甜味超标
    2020-12-22 06:01

    Use css only: if you are using single modal (not using multiple modals, I means not using modal over another modal)

    .modal-open{
        overflow: auto;
        padding-right:0 !important;
    }
    

    Use css and jquery script both: if you are using multiple modals, I means using modal over another modal). Note: add jquery script after jquery file

    .modal-open{
            overflow: auto;
            padding-right:0 !important;
        }
    
    
    $(document).on('show.bs.modal', '.modal', function () {
         $("body").css("padding-right","0");
    });
    
    $(document).on('hide.bs.modal', '.modal', function () {
         $("body").css("padding-right","0");
    });
    

提交回复
热议问题