css - 如何在 CSS 中继承类值

标签 css inheritance frontend

如何从 a:link、a:visited、a:active 继承到 .menunav:hover

我有这样的代码

a:link, a:visited, a:active {
   color: white !important;
   text-decoration: none !important;
}

.menunav:hover {
   color: white !important;
   text-decoration: none !important;
   background: #333;
   transition-duration: 0.5s;
}

我要继承

颜色:白色!重要; 文本装饰:无!重要;

最佳答案

要在第二个元素类型中使用这些属性,您可以像上面那样将属性复制粘贴到第二个规则中,或者让选择器出现在两个规则中。

a:link, a:visited, a:active, .menunav:hover {
   color: white !important;
   text-decoration: none !important;
}

.menunav:hover {
   background: #333;
   transition-duration: 0.5s;
}

关于css - 如何在 CSS 中继承类值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38647951/

相关文章:

c# - 我们可以使用基类对象访问派生类属性吗?

scala - 定义依赖于隐式的抽象类或特征

javafx:make stage 打印另一种方法

html - 如何在html页面中画圆圈?

c# - 当您将文本转换设置为大写的链接时,LinkText 不起作用

html - 在混合宽度的导航元素上从右侧滑入背景图像

javascript - 如何在 react-bootstrap 中更改我的 5 个选项卡之一的颜色?

css - 在 Chrome 中通过字体粗细和字体样式重置 OpenType 设置

java - 编译错误: constructor A in class A cannot be applied to given types

javascript - 使用 vanilla JavaScript 控制 CSS 动画