html - 使用 CSS 覆盖 anchor > 图像行为

标签 html css xhtml

注意:我在 5 分钟前问过类似的问题,但是这不一样......

我有这个 CSS 规则来给链接加下划线,而不通过任何字母的“脚”划线:

a:hover, a:focus, a:active {
    color: #3b234a;
    border-bottom: 1px #ccc solid;
}

现在这按预期工作了,但是我想编写一个规则来禁用链接图像上的此行为,如下所示:

<a href="#"><img src="..." /></a>

这可能吗?

谢谢。

最佳答案

然后将类“imageLink”或您喜欢的任何内容添加到保存图像的 anchor :

a:hover, a:focus, a:active {
  color: #3b234a;
  border-bottom: 1px #ccc solid;
}

a.imageLink:hover, a.imageLink:focus, a.imageLink:active {
   border-bottom: none;
}

关于html - 使用 CSS 覆盖 anchor > 图像行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3303081/

相关文章:

html - 将 Fontawesome-icon 与 w3-input 字段放在同一行

javascript - 如何像页脚一样将div卡住到页面底部

html - 设置溢出 :auto, 但不显示水平滚动条

Javascript 元素淡入淡出间隔无法正常工作

javascript - 光标继续显示 - 尽管它被设置为无,并且仅当在 div 上时。 Angular2/Javascript

html - 时间轴,使用 css 和 bootstrap 3

twitter-bootstrap - 在 Bootstrap 4 SCSS 中,你将响应式 mixins 放在哪里?

xml - 为什么我写<div/>之类的东西浏览器会卡死?

html - 无法确定页面中的字体和样式

css - 在 DIV 中加载 HTML 页面