Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS hide scroll bar, but have element scrollable

Tags:

html

css

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.

like image 977
user979331 Avatar asked Apr 03 '17 13:04

user979331


People also ask

How do I hide horizontal scrollbar but still scroll?

To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML. CSS.

How can I hide scrollbar in iframe but still scroll?

1. Set the overflow of the parent div as hidden. 2. Set the overflow of the child div to auto and the width 200% (or anything more than 100%, or more than the width of the parent - so that the scrollbar gets hidden).

How do I hide the scroll bar in inactivity?

There are many ways to hide the scroll bar when the page is inactive. One such way is using the onscroll, onmousewheel, onclick and onmousemove events, which help us to achieve our goal using basic HTML and JavaScript.


2 Answers

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

like image 153
Kiloumap Mrz Avatar answered Sep 25 '22 08:09

Kiloumap Mrz


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;   } } 
like image 36
danielricecodes Avatar answered Sep 23 '22 08:09

danielricecodes