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:
Adding padding to an inner div
, as in the currently accepted answer, won't work if for some reason you want to use box-model: border-box
.
What does work in both cases is increasing the width of the inner div
to 100% plus the scrollbar's width (assuming overflow: hidden
on the outer div).
For example, in CSS:
.container2 {
width: calc(100% + 19px);
}
In JavaScript, cross-browser:
var child = document.getElementById('container2');
var addWidth = child.offsetWidth - child.clientWidth + "px";
child.style.width = 'calc(100% + ' + addWidth + ')';