M
M
misha912012-04-01 23:08:48
css
misha91, 2012-04-01 23:08:48

How to hide the scrollbar in a div and set aside the ability to scroll?

You need to hide the scrollbar, but leave the scrolling option (for example, using the mouse wheel).
Or maybe make the scrollbar transparent somehow?

Answer the question

In order to leave comments, you need to log in

11 answer(s)
A
Andrey, 2014-10-21
@standy

If you do as advised above, then mobile browsers will suffer. They scroll does not take up space, as on desktops, so the text will go beyond the right border.
There is another solution:

/* хром, сафари */
.element::-webkit-scrollbar { width: 0; }

/* ie 10+ */
.element { -ms-overflow-style: none; }

/* фф (свойство больше не работает, других способов тоже нет)*/
.element { overflow: -moz-scrollbars-none; }

From here: hiding-vertical-scrollbars-with-pure-css-in-chrome...

D
DotDash, 2019-02-16
@DotDash

Hey! It's 2019 now and it works like this:

R
roliyarnik, 2017-02-01
@roliyarnik

this is how it works

W
WebgeekS, 2021-04-17
@WebgeekS

100% working Chrome, Safari, IE etc

.elem {
      overflow: auto;
      -ms-overflow-style: none;
      scrollbar-width: none;
}

.elem::-webkit-scrollbar {
      width: 0;
      height: 0;
}

A
Anatoly, 2012-04-02
@taliban

jsfiddle.net/H8xfD/ Use, but on condition that the width is known. The comment above is 100% correct.

J
JerryJJ, 2012-04-02
@JerryJJ

And then hope that the person will guess about the possibility of scrolling? Or draw your own scrollbar?

S
saneq1, 2020-04-04
@saneq1

scrollbar-width: none for mozilla
::-webkit-scrollbar for others

K
krom9ra, 2012-04-01
@krom9ra

In the style - overflow:hidden, and the events of the wheel will have to be processed by yourself.
Other options are detailed here.

M
Metaller, 2012-04-01
@Metaller

Try www.kelvinluck.com/assets/jquery/jScrollPane/jScrollPane.html

S
splitface, 2012-04-07
@splitface

What if the right margin is negative, and the parent has overflow:hidden .

D
daniel_wesson, 2017-12-21
@daniel_wesson

There is a good option:

<div class="div1">
  <div class="div2">
    Тут контент
  </div>
</div>

.div1 {
  width: 300px;
  height: 500px;
  overflow: hidden;
}
.div2 {
  overflow-y: scroll;
  max-height: 100%;
  width: 100%;
  padding-right: 45px;
  background: lightpink;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question