简体   繁体   English

CSS为什么overline不会在悬停时改变颜色和样式?

[英]CSS Why overline doesn't change color and style on hover?

im trying to do links that when you :hover appears an overline with a diferent color than the text, here's the code it seems to be correct for me but doesn't work and i dont know why :S 我正在尝试做一个链接,当您:hover出现的轮廓线与文本的颜色不同时,以下代码对我来说似乎是正确的,但是不起作用,我也不知道为什么:S

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

JSFiddle 的jsfiddle

text-decoration-color is only supported in Firefox and Safari. text-decoration-color仅在Firefox和Safari中受支持。 Take a look at the docs here, https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-color 看看这里的文档, https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-color

If you want to do this you could do it like this 如果您想这样做,可以这样做

.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: ' ';
}

Take a look at the updated fiddle here: https://jsfiddle.net/ytq235an/6/ 在这里查看更新的小提琴: https : //jsfiddle.net/ytq235an/6/

It seems to be only supported by Firefox. 似乎只有Firefox支持。 w3schools text-decoration-style w3schools文字装饰风格

If you want the overline to show up when you hover over the div 如果您希望将悬停在div上方时显示上划线

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

text-decoration-color is only supported in Firefox ( check reference here ) text-decoration-color仅在Firefox中受支持( 请在此处查看参考


Posible solution to your problem: 可能的解决方案:

.subboto a:hover {
    border-top: 1px dashed #f7a319;
}

JSFiddle 的jsfiddle

A quick google search brought me to this tutorial: http://www.w3schools.com/cssref/css3_pr_text-decoration-color.asp 谷歌快速搜索将我带到了本教程: http : //www.w3schools.com/cssref/css3_pr_text-decoration-color.asp

I clicked the "try it yourself" button but the underline wasn't red as it should be. 我单击“自己尝试”按钮,但下划线不是应该的红色。 The text states that it is not supported in any of the major browsers, but firefox does have a custom option. 文字指出,任何主流浏览器均不支持该功能,但是firefox确实具有自定义选项。

Unless you're fine with it only working on firefox, you're going to have to go about it a different way 除非您只在firefox上工作,否则您将不得不以其他方式进行操作

REFER TO THIS IMAGE: http://i.stack.imgur.com/qbTXE.png 参考此图片: http : //i.stack.imgur.com/qbTXE.png

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM