How to combine cursor: not-allowed and pointer-events: none;

user4420255 picture user4420255 · Oct 10, 2017 · Viewed 28.1k times · Source

How can I combine CSS cursor: not-allowed and pointer-events: none; not-allowed seems not to appear

.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }
.pointer-events-none { pointer-events: none; }
<button class="cursor-default">cursor-default</button>
<button class="cursor-not-allowed">cursor-not-allowed</button>
<button class="pointer-events-none">pointer-events-none</button>
<button class="cursor-not-allowed pointer-events-none">cursor-not-allowed + pointer-events-none</button>

Small sample, please have a look a the forth button cursor: not-allowed did'nt look the button, but show an looked icon.

Answer

Pedram picture Pedram · Oct 10, 2017

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.

.pointer-events-none {
    pointer-events: none;
}

.wrapper {
    cursor: not-allowed;
}
<div class="wrapper">
<button class="pointer-events-none">Some Text</button>
</div>

Add CSS cursor property when using "pointer-events: none"