弹出窗口,固定滚动条浏览器不跳动

参考
https://www.zhangxinxu.com/wordpress/2015/01/css-page-scrollbar-toggle-center-no-jumping/
https://v3.bootcss.com/javascript/#%E5%8A%A8%E6%80%81%E5%AE%9E%E4%BE%8B
https://segmentfault.com/a/1190000017044563?utm_source=tag-newest
知乎弹窗:
计算滚动条宽度的方法

1
2
3
const mr = window.innerWidth - document.body.clientWidth;
document.body.style.marginRight = `${mr}px`;
document.body.style.overflow = 'hidden';