I want to be able to scroll through the whole page, but without the scrollbar being shown.
In Google Chrome it's:
::-webkit-scrollbar {
display: none;
}
But Mozilla Firefox and Internet Explorer don't seem to work like that.
I also tried this in CSS:
overflow: hidden;
That does hide the scrollbar, but I can't scroll anymore.
Is there any way I can remove the scrollbar while still being able to scroll the whole page? With just CSS or HTML, please.
This is how I do it for horizontal scroll, only CSS and works well with frameworks like bootstrap / col-*. It only needs 2 extra div and the parent with a width or max-width set:
You can select the text to make it scroll or scroll it with fingers if you have a touchscreen.
Short version for lazy people:
Easy in Webkit, with optional styling:
My problem : I don't want any style in my html, I want directly my body scrollable without any scrollbar, and only a vertical scroll, working with css-grids for any screen size.
The box-sizing value impact padding or margin solutions, they works with box-sizing:content-box.
I still need the "-moz-scrollbars-none" directive, and like gdoron and Mr_Green, I had to hide the scrollbar. I tried -moz-transform and -moz-padding-start, to impact only firefox, but there was responsive side effects that needed to much work.
This solution works for html body content with "display: grid" style and it is responsive.
Another simple working fiddle.
Overflow hidden on the parent container, and overflow auto on the child container. Simple.
Adding padding to an inner
div
, as in the currently accepted answer, won't work if for some reason you want to usebox-model: border-box
.What does work in both cases is increasing the width of the inner
div
to 100% plus the scrollbar's width (assumingoverflow: hidden
on the outer div).For example, in CSS:
In Javascript, cross-browser: