How to combine cursor: not-allowed and pointer-eve

2019-04-07 08:07发布

问题:

This question already has an answer here:

  • Add CSS cursor property when using “pointer-events: none” 3 answers

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.

回答1:

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"



标签: css css3 cursor