CSS 如何组合 cursor: not-allowed 和 pointer-events: none;

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46665625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:45:01  来源:igfitidea点击:

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

csscursor

提问by Pedram

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

如何结合 CSS cursor: not-allowed 和 pointer-events: none; not-allowed 好像没有出现

.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.

小样,请看第四个按钮光标:not-allowed 不看按钮,但显示一个看图标。

回答by Pedram

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 divthen use cursor: not-allowed;on this.

你不能这样做,因为pointer-events: none;禁用所有鼠标功能,但你可以做一个技巧并用一个div然后使用它cursor: not-allowed;来包裹你的按钮。

.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"

使用“pointer-events: none”时添加CSS光标属性