Bootstrap Modals keep adding padding-right to body after closed

后端 未结 30 1995
南方客
南方客 2020-12-12 12:36

I am using bootstrap and Parse framework to build a small webapp. But those Bootstrap modals keep adding padding-right to body after closed. How to solve this?

I tri

30条回答
  •  甜味超标
    2020-12-12 13:18

    If you're more concerned about the padding-right related thing then you can do this

    jQuery:

    $('#loginModal').on('show.bs.modal', function (e) {
         $('body').addClass('test');
    });
    

    this will addClass to your body and then using this

    CSS:

    .test[style] {
         padding-right:0 !important;
     }
    

    and this will help you to get rid of padding-right.

    But if you're also concerned about the hiding scroll then you've to add this too:

    CSS:

    .test.modal-open {
        overflow: auto;
     }
    

    Here's the JSFiddle

    Please have a look, it will do the trick for you.

提交回复
热议问题