Hide vertical scrollbar, keep horizontal and still able to scroll
You can use -webkit-scrollbar
, but you need to use width
and height
instead of display: none
div { width: 100px; height: 100px; font-size: 48px; overflow: auto;}
::-webkit-scrollbar { height: 0px; width: 8px; border: 1px solid #fff;}
::-webkit-scrollbar-track { border-radius: 0; background: #eeeeee;}
::-webkit-scrollbar-thumb { border-radius: 0; background: #b0b0b0;}
<div>Lorem ipsum dolor sit amet.</div>
Shift scroll to move horizontally
Hide html horizontal but not vertical scrollbar
You can use css like this:
overflow-y: scroll;
overflow-x: hidden;
How do I hide horizontal scroll bar and keep vertical scroll bar visible while still being able to scroll horizontally?
Try this:
.section {
overflow-x: scroll;
scrollbar-width: none;
overflow-y: auto;
}
.section::-webkit-scrollbar {
display: none;
}
How to hide vertical scrollbar without hiding horizontal scrollbar and still be able to scroll?
Customizing scrollbars is a cross-browser compatibility problem as Firefox limits you a lot.
For WebKit browsers you can set the width
and height
on scrollbars!
::-webkit-scrollbar
{
width: 0;
height: 8px;
}
This hides the vertical scrollbar but keeps the horizontal. It also removes default scrollbar style, so it needs to be corrected.
::-webkit-scrollbar
{
width: 0;
height: 1.2rem;
}
::-webkit-scrollbar-track
{
background: white;
}
::-webkit-scrollbar-thumb
{
background: hsl(0, 0%, 60%);
}
body
{
width: 1500px;
height: 1000px;
background: url('https://random.imagecdn.app/1920/1080');
}
Hiding horizontal scroll bar while keeping it active and keeping the vertical one
.wrap {
width: 100%;
height: 100%;
overflow-x: scroll;
}
.inner {
width: 200%;
}
.wrap::-webkit-scrollbar {
display: none;
}
<div class="wrap">
<div class="inner">
</div>
</div>
HTML and enable div's horizontal scrolling but hide the horizontal scrollbar
There's a similar question Hide scroll bar, but still being able to scroll, but I believe your question is focused on the horizontal scrollbar. In that other question, I found something that can help you, this answer. Jean posted that answer where he puts margin-bottom: -17px;
in the container's child to hide the scrollbar.I did a simple jsFiddle to ilustrate his technique. It's a hack to hide the scrollbar, I didn't check if this work on all major browses but it works on chrome and firefox.
Related Topics
Dynamically Aligning Pseudo Element According to Parent Height
CSS Object-Fit: Contain; Is Keeping Original Image Width in Layout
Using Z-Index to Get Div Above Another Div
How to Make the HTML5 Number Field Display Trailing Zeroes
How to Notify the HTML Container That the Swf Has Finished, Using Swfobject
How to Create a Hidden Div That Doesn't Create a Line Break or Horizontal Space
Can You Use CSS to Mirror/Flip Text
How to Scale a Stubborn Svg Embedded with the <Object> Tag
Set Date Input Field's Max Date to Today
Workaround for Href="File://///..." in Firefox
CSS Transition - Eases in But Doesn't Ease Out