移除:从文字悬停颜色,而不设置颜色 [英] Remove :hover color from text without setting the color

查看:140
本文介绍了移除:从文字悬停颜色,而不设置颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从文字中移除:hover color。然而,在这种情况下,知道什么是非悬浮颜色是不可能的。有没有办法设置颜色继承自其non:hover parent self?我可以看到和修改元素:hover CSS而不是元素CSS。

I would like to remove the :hover color from the text. However, knowing what the non-hover color is not possible in this case. Is there a way to set the color to inherit from its non :hover parent self? I can see and modify the element:hover CSS but not the element CSS.

澄清:我想让链接从它的非悬浮状态继承颜色,对元素的颜色没有影响。我在一个链接中封装了一个div,所以整个div将是一个链接,但我不想改变文本的颜色在div。我改变背景颜色。

Clarification: I want the link to inherit the color from its non-hovered state so that hovering does not have an effect on the element's color. I encapsulated a div in a link so that the entire div would be a link, but I don't want that to change the text's color inside the div. I am changing the background color instead.

推荐答案

你不能。 CSS中没有撤销。也就是说,如果一些样式表将元素的属性或元素的状态分配给某个元素,则无法告诉浏览器的行为,就像该规则不存在。你可以覆盖它的效果,但是这意味着将属性设置为一个值(可以 inherit ,但这不会有帮助,因为继承来自父级)。

You cannot. There is no undo in CSS. That is, if some style sheet assigns a property to an element, or to a state of an element, there is no way to tell a browser behave as if that rule were not there. You can override its effect, but this means setting the property to a value (which could be inherit, but that won’t help here, since inheritance is from a parent).

这篇关于移除:从文字悬停颜色,而不设置颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆