css设定不能点一下的办法是应用【pointer-events: none;】用于禁止使用鼠标的事情,根据多种方式关联的事情依然会触发的,例如键盘事件等。
本实例教程作业环境:windows7系统软件、css3版,DELL G3计算机。
css设定不能点一下的办法:
css编码:
.disable {
pointer-events: none;
}
实例:
const disabled = true;
<Button className={disabled ? 'disabled' : null}>点一下</Button><style>
.disabled {
pointer-events: none;
// 设定pointer-events: none;再设定cursor是没有用的
}</style>
设计效果图:
留意:
pointer-events 数值为 none 时,假如原素上相对定位,那么在它下一层元素能够被选中。
pointer-events: none; 就是用来禁止使用鼠标的事情,根据多种方式关联的事情依然会触发的,例如键盘事件等。
如果把一个元素子元素 pointer-events 设成别的值(例如:auto),因此当点一下子元素时,依然会根据事件冒泡的方式考虑父元素事件。
有关实例教程强烈推荐:CSS视频教学
以上就是关于css怎么设置不能单击的具体内容,大量欢迎关注AdminJS其他类似文章!