[英]scrollbar-width: none; VS overflow-x: hidden
It seems that I can use both these to hide the horizontal scrollbar of an element: 看来我可以同时使用这两个元素来隐藏元素的水平滚动条:
overflow-x: hidden;
scrollbar-width: none;
Which one is the better solution for hiding the horizontal scrollbar? 哪一种是隐藏水平滚动条的更好解决方案?
overflow-x: hidden
will clip any content inside a parent element (say the page) that has a width that overflows out of the parent and prevent the user from scrolling horizontally. overflow-x: hidden
将剪切父元素(例如页面)中宽度超出父元素并阻止用户水平滚动的任何内容。 Source 资源
scrollbar-width: none
hides the scrollbar however the content will still be scroll able. scrollbar-width: none
隐藏滚动条,但是内容仍然可以滚动。 Source 资源
So it depends upon what you are trying to achieve. 因此,这取决于您要实现的目标。
With scrollbar-width: none;
使用
scrollbar-width: none;
the scrollbar is still present and you can still scroll if there is overflow, if you want to disable scrolling at all use overflow: hidden;
滚动条仍然存在,如果有溢出,如果您想完全禁用滚动,则仍可以滚动
overflow: hidden;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.