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. Source
scrollbar-width: none
hides the scrollbar however the content will still be scroll able. Source
So it depends upon what you are trying to achieve.
With 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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.