0
如何将类属性应用于在纯CSS中具有选择器的类?例如:CSS选择器 - 如何在选择器的事件上应用定义的类
.one{color:red;}
.two{color:blue;}
.two:hover{ /*Apply class ".one" to class ".two" when the event is triggered */}
如何将类属性应用于在纯CSS中具有选择器的类?例如:CSS选择器 - 如何在选择器的事件上应用定义的类
.one{color:red;}
.two{color:blue;}
.two:hover{ /*Apply class ".one" to class ".two" when the event is triggered */}
很简单:
.two {
color: blue;
}
.one, .two:hover {
color: red;
}
希望这有助于! 如果你曾经移植到SASS,你可以做一个像这样的小清洁工:
.one {
color: blue;
}
.two {
color: red;
&:hover {
@extend .one;
}
}
逗号分隔的类共享属性将完成这项工作。谢谢! – ProtectedVoid
CSS没有继承。要达到这个目标,你必须使用CSS预处理器。 –