bootstrap點彈跳視窗時,會出現element.style{padding-right:17px} 使整個頁面右邊會越來越往左偏移
說明:
遇到的專案是有使用sweetalert,所以使用方法5的方法有自訂了一下,
不然也可以參考該網址
https://stackoverflow.com/questions/32862394/bootstrap-modals-keep-adding-padding-right-to-body-after-closed
https://forums.oscommerce.com/topic/412058-modal-destination-and-modal-within-modal/
解決方法:
方法1
body {
padding-right: 0 !important;
overflow-y: scroll!important;
}
方法2
body,body.swal2-shown,body.modal-open {
overflow:inherit;
padding-right:inherit !important;
}
方法3
$(document.body).on('hide.bs.modal,hidden.bs.modal', function () {
$('body').css('padding-right', '0');
});
方法4
('.modal').on('hide.bs.modal', function (e) {
e.stopPropagation();
$('body').css('padding-right', '');
});
方法5
body, body.swal2-shown, body.modal-open {
padding-right: 0 !important;
overflow-y: scroll !important;
}