Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the CSS cursor property not work for the styled scrollbar?

Tags:

html

css

I've styled a scrollbar, but cursor pointer is not working, even after I put !important.

::-webkit-scrollbar {
  width: 0.3vw;
  height: 20px;
  padding: 2px;
  cursor: pointer !important;
}


/* Handle */

::-webkit-scrollbar-thumb {
  background-color: #808080;
  border-radius: 70px;
  padding: 2px;
  cursor: pointer !important;
}


/* Handle on hover */

::-webkit-scrollbar-thumb:hover {
  background-color: #424242;
  cursor: pointer !important;
}

::-webkit-scrollbar-track {
  background-color: transparent;
  cursor: pointer !important;
}

body {
  height: 90000px;
}

I tried and ran it out. I don't see it working. Can you help me get cursor: pointer for ::-WebKit-scrollbar. Here are some links for where you can find the scrollbar and cursor pointer:

1

2

3

4

5

6

7

like image 951
Green Avatar asked Oct 17 '20 12:10

Green


People also ask

Why is my cursor pointer not working?

Check that the battery of the mouse is charged. Make sure that the receiver (dongle) is firmly plugged in to the computer. If your mouse and receiver can operate on different radio channels, make sure that they are both set to the same channel.

Can you style the scrollbar CSS?

As of 2020, 96% of internet users are running browsers that support CSS scrollbar styling. However, you will need to write two sets of CSS rules to cover Blink and WebKit and also Firefox browsers. In this tutorial, you will learn how to use CSS to customize scrollbars to support modern browsers.

How do I fix the scroll bar in CSS?

The easy fix is to use width: 100% instead. Percentages don't include the width of the scrollbar, so will automatically fit. If you can't do that, or you're setting the width on another element, add overflow-x: hidden or overflow: hidden to the surrounding element to prevent the scrollbar.

How do I change the scrollbar cursor?

In order to customize the scrollbar, you have to use ::-webkit-scrollbar property. You can specify the width of the scrollbar and also set the scrollbar track or path by setting the background property. Furthermore, you can also add some hover effect on ::-webkit-scrollbar-thumb .


Video Answer


1 Answers

Unfortunately due to this BUG fix of webkit, chrome will use the parent's cursor style for the child container.

You can fix your issue by just adding the following CSS:

HTML {
  cursor: pointer;
}

body {
  cursor: default;
  ...
}

::-webkit-scrollbar {
  width: 10px;
  height: 20px;
  padding: 2px;
  cursor: pointer !important;
}


/* Handle */

::-webkit-scrollbar-thumb {
  background-color: #808080;
  border-radius: 70px;
  padding: 2px;
  cursor: pointer !important;
}


/* Handle on hover */

::-webkit-scrollbar-thumb:hover {
  background-color: #424242;
  cursor: pointer !important;
}

::-webkit-scrollbar-track {
  background-color: transparent;
  cursor: pointer !important;
}

html {
  cursor: pointer;
}

body {
  cursor: default;
  height: 90000px;
}
<html>

<body>
  <div>
    <h1>Hello</h1>
  </div>
</body>

</html>
like image 112
Dipen Shah Avatar answered Nov 15 '22 05:11

Dipen Shah