CSS to hide scrollbar from Mozilla Firefox as we can hide it from chrome like:-
::-webkit-scrollbar
CSS to hide scrollbar from Mozilla Firefox as we can hide it from chrome like:-
::-webkit-scrollbar
You can do the following
<div style='width: 100%;height:300px;'>
<div style='height: 100%; overflow: auto; margin-right: -15px;'>
//your overflowing content
</div>
</div>
Here height in parent div depends on your usecase.
The margin-right property in the inner div is the scrollbar width that can be computed from javascript as follows.
var div = document.createElement('div');
div.setAttribute('style', "width: 100%;height: 100%;position: absolute;overflow: auto;visibility: hidden;");
document.body.appendChild(div);
div.innerHTML = '<div style="width: 100%;height: 200%;"></div></div>';
var scrollWidth = div.offsetWidth - div.clientWidth;
div.parentNode.removeChild(div);
return scrollWidth;
You have to set the returned 'scrollWidth' data as negative 'margin-right' to the child container.
This will work on all browsers.
NOTE: The margin-right property should be set after checking whether the content is overflowing. Or else you will have some width problems.
There are many ways:
body {
srollbar-width: none
}
::-webkit-scrollbar {
background: transparent;
}