89

I have this element called items and the content inside the element is longer than the element height, I want to make it scrollable but hide the scroll bar, how would I do that?

<div class="left-side">
    <div
      class="items"
      style="display:block;width: 94%;margin: 0 auto;overflow: hidden;"
    >
    </div>
</div>
.left-side {
    height: 878px;
    padding-top: 20px;
    width: 1470px;
}

I tried setting the left-side class overflow to auto, but that didn't do anything.

Esteban Borai
  • 2,311
  • 1
  • 21
  • 27
user979331
  • 11,039
  • 73
  • 223
  • 418
  • 1
    Possible duplicate of [Hiding the scrollbar on an HTML page](http://stackoverflow.com/questions/3296644/hiding-the-scrollbar-on-an-html-page) – Troyer Apr 03 '17 at 13:36
  • 2
    "*[..]I want to make it scrollable but hide the scroll bar*" -- That would be horrible! Scrollbars have a purpose, and that purpose is to scroll. – Abhitalks Apr 03 '17 at 13:36
  • 2
    Possible duplicate of [Hide scroll bar, but still being able to scroll](http://stackoverflow.com/questions/16670931/hide-scroll-bar-but-still-being-able-to-scroll) – Abhishek Pandey Apr 03 '17 at 13:38
  • 2
    Yes, @Abhitalks is correct: that would break the usability of the page.Do hide the scrollbar if it is not needed; don't hide it if there is more content below the fold. https://www.nngroup.com/articles/scrolling-and-scrollbars/ – Yvonne Aburrow Apr 03 '17 at 13:38

10 Answers10

179

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

Saad
  • 3,340
  • 2
  • 10
  • 32
Kiloumap Mrz
  • 2,133
  • 1
  • 9
  • 18
86

I combined a couple of different answers in SO into the following snippet, which should work on all, if not most, modern browsers I believe. All you have to do is add the CSS class .disable-scrollbars onto the element you wish to apply this to.

.disable-scrollbars::-webkit-scrollbar {
  background: transparent; /* Chrome/Safari/Webkit */
  width: 0px;
}
    
.disable-scrollbars {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE 10+ */
}

And if you want to use SCSS/SASS:

.disable-scrollbars {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE 10+ */

  &::-webkit-scrollbar {
    background: transparent; /* Chrome/Safari/Webkit */
    width: 0px;
  }
}
Esteban Borai
  • 2,311
  • 1
  • 21
  • 27
danielricecodes
  • 3,446
  • 21
  • 23
12

Hope this helps

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
html {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}
Isaac Hunter
  • 121
  • 1
  • 4
8

Similar to Kiloumap L'artélon's answer,

::-webkit-scrollbar {
    display:none;
}

works too

hellomello
  • 8,219
  • 39
  • 151
  • 297
  • 4
    This only works on desktop chrome. It doesn't work on any other browser I've tested on. – whaley Dec 27 '18 at 22:20
  • 1
    `width: 0;` seems to hide the horizontal scrollbar, but leaves a weird empty gap on Chrome desktop 83. `display: none;` does not have this issue. I threw in both just to be safe. – cyqsimon Jun 29 '20 at 08:21
4

work on all major browsers

html {
    overflow: scroll;
    overflow-x: hidden;
}
::-webkit-scrollbar {
    width: 0px;  /* Remove scrollbar space */
    background: transparent;  /* Optional: just make scrollbar invisible */
}
Chukwuemeka Maduekwe
  • 6,687
  • 5
  • 44
  • 67
3

You can hide it on specific div usig class:

<div class="hide-scroll"></div>
.hide-scroll{
    overflow: scroll;
}

.hide-scroll::-webkit-scrollbar {
    background: transparent; /* make scrollbar transparent */
    width: 0px;
}
Esteban Borai
  • 2,311
  • 1
  • 21
  • 27
Rizwan
  • 3,741
  • 2
  • 25
  • 22
1

if you really want to get rid of the scrollbar, split the information up into two separate pages.

Usability guidelines on scrollbars by Jakob Nielsen:

There are five essential usability guidelines for scrolling and scrollbars:

  • Offer a scrollbar if an area has scrolling content. Don't rely on auto-scrolling or on dragging, which people might not notice.
  • Hide scrollbars if all content is visible. If people see a scrollbar, they assume there's additional content and will be frustrated if they can't scroll.
  • Comply with GUI standards and use scrollbars that look like scrollbars.
  • Avoid horizontal scrolling on Web pages and minimize it elsewhere.
  • Display all important information above the fold. Users often decide whether to stay or leave based on what they can see without scrolling. Plus they only allocate 20% of their attention below the fold.

To make your scrollbar only visible when it is needed (i.e. when there is content to scroll down to), use overflow: auto.

Yvonne Aburrow
  • 2,602
  • 1
  • 17
  • 47
  • 4
    This is nice and sensible, but sometimes you _really_ want to do things that sound strange without the context. For example, if you have a complex table component with one or more splitter, and the sections are scroll-synced, you only want the scrollbar on one section because it's obvious for the user that the whole thing is scrollable as one unit and individual scrollbars only add confusion. – Andy Mikhailenko Jan 21 '19 at 17:30
  • 3
    This doesn't really answer the question – Kalimantan Feb 26 '19 at 19:58
  • 1
    You effectively told the OP that what he is trying to do is wrong. There are cases where it is right (a carousel is the most common one). In the case of a carousel, there is some other UI element that indicates the drag capability (arrows rendered by the application and/or position dots). – Adam Leggett Apr 26 '20 at 17:22
  • so far this answer has had 7 upvotes and 5 downvotes. It seems that opinion is divided. If it was getting downvoted by everyone, I would just delete it, but since it's not, I am leaving it up. – Yvonne Aburrow Jan 20 '21 at 19:42
1

You can make use of the SlimScroll plugin to make a div scrollable even if it is set to overflow: hidden;(i.e. scrollbar hidden).

You can also control touch scroll as well as the scroll speed using this plugin.

Hope this helps :)

Sudipto
  • 440
  • 2
  • 8
1

if you use sass, you can try this

&::-webkit-scrollbar { 
  width: 0px;
  background: transparent; /* make scrollbar transparent */
}
Erik P_yan
  • 608
  • 5
  • 6
0

Just add this to your css and the job is done...

/* Hide scrollbar for Chrome, Safari and Opera */
body::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
body {
  overflow: -moz-scrollbars-none;
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}