Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change cursor for disabled <button> or <a> in Bootstrap 4?

How can I use cursor: not-allowed on button or a? I tried the following:

.not-allowed {
     pointer-events: auto! important;
     cursor: not-allowed! important;
}

My button looks like this:

<a class="btn btn-primary btn-lg disabled not-allowed" href="https://www.example.com" role="button">Test</a>

Without the pointer-events is activated, the cursor can not be changed. But if pointer-events: auto, the button or a is clickable. If the pointer-events: none the cursor doesn't change.

Please help me, I despair!

like image 849
PaT Avatar asked Oct 02 '22 23:10

PaT


People also ask

How do I change my cursor style?

To change how the mouse pointer looks In the search box, type mouse, and then click Mouse. Click the Pointers tab, and then do one of the following: To give all of your pointers a new look, click the Scheme drop-down list, and then click a new mouse pointer scheme.

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.

How do you combine cursor not allowed and pointer events none?

you can't do this because pointer-events: none; disable all mouse functions, but you can do a trick and wrap your button with a div then use cursor: not-allowed; on this. Work great.


Video Answer


3 Answers

This is actually a bug in Bootstrap

The proposed solutions :

button:disabled {
  cursor: not-allowed;
  pointer-events: all !important;
}

or if you have this kind of structure :

<li class="disabled">
  <a href="#">My Link</a>
</li>

then

li.disabled {
  cursor: not-allowed;
}
li.disabled a {
  pointer-events: none;
}
like image 117
Mohamed Ramrami Avatar answered Oct 23 '22 10:10

Mohamed Ramrami


Use this:

.not-allowed {
     cursor: not-allowed !important;
}
like image 40
renuka Avatar answered Oct 23 '22 10:10

renuka


You can wrap your button in span like below

<span>
   <button> click me </button>
</span>

Now in css don't allow pointer events on button and make cursor disabled for wrapper.

 button {
     pointer-events: none;
     opacity: 0.7
   }


   span {
       cursor: not-allowed;
   }
like image 12
Santosh Kadam Avatar answered Oct 23 '22 10:10

Santosh Kadam