Vertical Scrollbar Position Absolute

别说谁变了你拦得住时间么 提交于 2020-01-13 05:14:58

问题


Is there a way to have a cross browser vertical scrollbar with an absolute position?

My problem is that the scrollbar changes the width of my website when appears by giving some issues in my layout.

I do not want to remove it, I just want to make its width not disturbing my layout..

Thanks!


回答1:


To stop your layout from moving when the scrollbar appears, you can use the css below to always make your scrollbar visible.

html{
    overflow-y: scroll;
}



回答2:


Only in Safari and Chrome (ie. Webkit), you can also use:

html{
    overflow-y: overlay;
}

It will add a scroll bar only when necessery, and put it above your content, which means it will not disturb your layout. Use with caution though, it's proprietary and undocumented.




回答3:


always display it to not disturb your layout. it's what Google do ;)



来源:https://stackoverflow.com/questions/6999257/vertical-scrollbar-position-absolute

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!