【发布时间】:2017-12-18 13:37:12
【问题描述】:
我在颜色 (A) 的悬停上有一个下划线。我需要将它更改为选择内的另一种颜色(在突出显示的文本内)。
问题在于下划线不会改变突出显示(选定)文本内的颜色。
截图:
- 1) Here is a screenshot of the highlighted text without hover - this is correct
- 2) Here is a highlighted text with hover - it should show a black underline
请问有人知道如何使它在第二个屏幕截图中显示下划线,样式为黑色?
这是从@Pawan-Kumar 的答案中借用的经过简化和编辑的代码示例(我的原始代码令人困惑):
.link{
color:blue;
cursor:pointer;
}
.link:hover{
color:lightblue;
text-decoration: underline;
text-decoration-color: red;
}
.link::selection{
background-color:lightblue;
}
.link:hover::selection{
background-color:yellow;
text-decoration-color: black; /* This does not work*/
}
<span class='link'>This link</span> should have black underline inside highlighted text.
【问题讨论】:
-
我认为问题可以简化如下:是否可以在一个跨度/ div 内将高亮和非高亮下划线设置为不同的颜色?
标签: css sass hover selection underline