有没有一种方法可以实现:将实体悬停到内联链接



我正在研究HTML电子邮件签名,这必须使用基本的HTML来完成。我必须使用非常简单的CSS、表,并为所有内容声明内联CSS。总的来说,它工作得很好,但我有一个链接的问题。我可以条纹链接没有下划线或颜色:

<a style="text-decoration: none; color:inherit!important;" href="https://#">link</a>

但不知道是否有可能添加:悬停实体内联?

a: hover {text-decoration: underline;}

欢迎有任何想法!

没有等效的:在内联css中悬停。

你可以给你的锚标签一个类或id,并在那里更改你需要的属性

<a class="anchor"> link </a>

在您的css样式表中

.anchor{ 
text-decoration: none;
}

如果不想使用外部样式表,可以向元素添加onmouseover属性,如so

<a href="#" onmouseover="this.style.textDecoration='none'" onmouseout="this.style.color='red'"> Link </a>

内联样式具有更高的优先级。

简单地从元素中移除CCD_ 1。

a{
text-decoration: none; 
}
a:hover {
text-decoration: underline;
}
<a style="color:inherit!important;" href="https://#">link</a>

另一种方法是添加!重要,但它被认为是一个坏习惯:

a:hover{
text-decoration: underline !important;
}

最新更新