Bootstrap modal on hiding adds padding-right to html body

前端 未结 2 473
离开以前
离开以前 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");
    });
    
    0 讨论(0)
  • 2020-12-22 06:08

    This worked for me:

    body {
      padding-right:0 !important;
    }
    
    .modal-open {
      overflow:auto;
      padding-right:0 !important;
    }
    
    0 讨论(0)
提交回复
热议问题