css - 禁用一张特定图像的悬停不透明效果

标签 css hover opacity

我在图像上添加了悬停不透明效果,如下所示:

img {
  opacity: 1.0;
  filter: alpha(opacity=1.0); 
}
img:hover {
  opacity: 0.6;
  filter: alpha(opacity=0.6); 
}

我想对一张特定图像完全禁用此悬停效果。

如何实现这一目标?

最佳答案

为图像添加 ID,并将 CSS 更改为以下内容:

img{
    opacity: 1.0;
    filter: alpha(opacity=1.0); 
}

img:not(#id):hover{
    opacity: 0.6;
    filter: alpha(opacity=0.6); 
}

使用 :not() 选择器,您可以排除某些元素

关于css - 禁用一张特定图像的悬停不透明效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34746401/

相关文章:

html - 使用 :target selector 关闭带有纯 css 的容器

html - 如何在悬停状态下影响兄弟元素?

html - 仅为外部 div 设置不透明度,而不是内部文本

Jquery append/html div 不工作,css 错误?

html - 过渡,我很困惑

css - 悬停属性适用于 child

javascript - 使用 JavaScript 超时后只允许 CSS 悬停事件

css - 没有设置top的时候,为什么位置: absolute div is not overlapped with its siblings

html - 无法控制div内图像的不透明度

css - 如何制作两个透明的div