Hide scroll bar, but while still being able to scroll
Just a test which is working fine.
#parent{
width: 100%;
height: 100%;
overflow: hidden;
}
#child{
width: 100%;
height: 100%;
overflow-y: scroll;
padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
box-sizing: content-box; /* So the width will be 100% + 17px */
}
Working Fiddle
JavaScript:
Since the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth
, the exact scrollbar width will show up.
JavaScript Working Fiddle
Or
Using Position: absolute
,
#parent{
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
}
#child{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
overflow-y: scroll;
}
Working Fiddle
JavaScript Working Fiddle
Information:
Based on this answer, I created a simple scroll plugin.
CSS hide scroll bar, but have element scrollable
You can hide it:
html {
overflow: scroll;
}
::-webkit-scrollbar {
width: 0px;
background: transparent; /* make scrollbar transparent */
}
For further information, see: Hide scroll bar, but while still being able to scroll
CSS hide scroll bar if not needed
Set overflow-y
property to auto
, or remove the property altogether if it is not inherited.
Allow scroll but hide scrollbar
It's better, if you use two div containers in HTML .
As Shown Below:
HTML:
<div id="container1">
<div id="container2">
// Content here
</div>
</div>
CSS:
#container1{
height: 100%;
width: 100%;
overflow: hidden;
}
#container2{
height: 100%;
width: 100%;
overflow: auto;
padding-right: 20px;
}
Remove scrollbar from iframe
in your css:
iframe{
overflow:hidden;
}
How to hide overflow scrollbar on Microsoft Chrome when there is no where to scroll?
Use the overflow-y
property and set it to auto
to enable the vertical scrollbar when it's needed.
Set overflow-x
to hidden
to disable horizontal scrolling altogether.
How to create scrollable element in Tailwind without a scrollbar
To hide the scrollbar you'll need to style it directly:
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
You could easily add these as Tailwind utilities using a plugin in your config: https://tailwindcss.com/docs/plugins#adding-utilities
Further reading:
https://css-tricks.com/almanac/properties/s/scrollbar/
https://www.w3schools.com/howto/howto_css_hide_scrollbars.asp
Related Topics
How to Make Images in a CSS Grid Lay Next to Each Other and Jump to Another Row When Lacking Space
Bootstrap 3.3.6 Warnings and Errors in Bootstrap.Min.CSS
Weird Issue with Chrome Inspect Element
Rounded Bottom Div Where Curve Angle Is Not Responsive
Translate + Canvas = Blurry Text
How to Make Three Columns The Same Height
CSS Linear Gradient for Div with Dynamic Height
Ie9 + CSS: Problem with Fixed Header Table
How to Set Bootstrap Col for Small Display Sizes
Webfont Does Not Apear Without Www
CSS, Transparent Text with Opaque Background
How to Use Sass/Scss in Angular Application
Mix Github Markdown Language with CSS
Select: Last-Child with Especific Class Name (With Only CSS)
CSS Column-Count Not Respected
Issue with: Global() CSS-Module Selectors Not Being Pure in Nextjs
Background Images Not Showing in Ie11
Cross-Browser CSS for Left Align and Right Align on The Same Line