html - CSS 为什么上划线在悬停时不会改变颜色和样式?

标签 html css colors hover

我正在尝试做一些链接,当你 :hover 出现一个颜色与文本颜色不同的上划线时,这里的代码对我来说似乎是正确的,但不起作用,我不知道为什么 :S

.subboto a:hover {
   text-decoration: overline;
   text-decoration-color: #f7a319;
   text-decoration-style: dashed;
}

JSFiddle

最佳答案

text-decoration-color 仅在 Firefox 和 Safari 中受支持。看看这里的文档,https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-color

如果你想这样做,你可以这样做

.subboto a:link, a:visited {
    text-decoration: none;
    color: black;
    position: relative;
}

.subboto a:hover:after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    border-top: 1px dashed #f7a319;
    content: ' ';
}

在这里查看更新后的 fiddle :https://jsfiddle.net/ytq235an/6/

关于html - CSS 为什么上划线在悬停时不会改变颜色和样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29835549/

相关文章:

html - 试图在 html 中显示元素符号文本

javascript - 在 html 中创建和链接 div 标签

android - 如何更改存储在 strings.xml 中的字符串中某些单词的颜色?

java - 使用 StAX API 编写 html

javascript - fancybox-wrap高度变化时如何调用fancybox resize函数

CSS 在突出显示的选择之间改变颜色?

colors - 有没有一种简单的方法可以为 MediaWiki 维基页面指定特定的背景颜色?

java - 为背景创建状态列表可绘制 XML - Android

javascript - 使用 document.getElementById 捕获innerHTML

html - 负边距元素仅在一种情况下被剪裁在 div 之外?