How do I remove the horizontal scrollbar in a div?
overflow-x: hidden;
Don't forget to write overflow-x: hidden;
The code should be:
overflow-y: scroll;
overflow-x: hidden;
CSS
overflow-y: scroll;
See it on jsFiddle.
Notice if you remove the -y
from the overflow-y
property, the horizontal scroll bar is shown.
With overflow-y: scroll
, the vertical scrollbar will always be there even if it is not needed. If you want y-scrollbar to be visible only when it is needed, I found this works:
.mydivclass {overflow-x: hidden; overflow-y: auto;}
Add this code to your CSS. It will disable the horizontal scrollbar.
html, body {
max-width: 100%;
overflow-x: hidden;
}