因高度滚动条而页面抖动

383 阅读1分钟

一、推荐:既不会抖动也能有滚动条
1.

html {
     margin-right: calc(100% - 100vw);
}

2.//要求兼容性

html {
      overflow-y: overlay;
}

二、不推荐: 1.页面滚动条一直存在

body {
      overflow-y: scroll
 } 

2.隐藏页面滚动条

::-webkit-scrollbar {
            background: transparent;
            width: 0px;
            height: 10px
        }

::-webkit-scrollbar-thumb {
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            background-color: #e1e1e1;
            width: 0px;
            height: 6px;
            border: 2px solid transparent;
            background-clip: content-box
        }

参考:t.csdn.cn/gbWzq; t.csdn.cn/HtJwy