CSS disable hover effect(CSS 禁用悬停效果)
问题描述
我需要禁用整个 DOM 中特定按钮(不是所有按钮)上的鼠标悬停.请告诉我如何使用 CSS 类来实现它.
I need to disable the mouse hover on a particular button(not on all buttons) in the entire DOM. Please let me know how to achieve it using a CSS class.
当我的按钮被禁用时,我正在使用下面的 CSS 类.现在我想使用同一个类来移除悬停效果.
i am using the below CSS class when my button is disabled. now i want to remove the hover effect using the same class.
.buttonDisabled
{
Cursor:text !important; Text-Decoration: None !important;
}
上面的类将负责删除鼠标悬停时的手势和文本下划线.现在我也想删除悬停效果.请告诉我.
The above class will take care of removing the hand sign and text underline on mouse over . Now i want to remove hover effect also. Please let me know.
推荐答案
我有一个非常简单的解决方案.
I have really simple solution for this.
创建一个新类
.noHover{
pointer-events: none;
}
并使用它来禁用它上面的任何事件.像这样使用它:
and use this to disable any event on it. use it like:
<a href='' class='btn noHover'>You cant touch ME :P</a>
这篇关于CSS 禁用悬停效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CSS 禁用悬停效果


- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01