如何解决我们可以在CSS中将两个规则合并为一个规则吗?
我有两个senario
类,分别从icn-
和in-betwen icn-
开始。两者都具有相同的属性。我们可以添加一个选择器或regex
吗? ?
.f20 [class^="icn-"]:before,.f20 [class*=" icn-"]:before {
font-family: 'icons' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale
}
解决方法
您可以编写以下内容:
.f20 [class*="icn-"]:before {
color: pink; /*whatever you want goes here*/
}
这将选择任何icn-
类,如果它在开始或其他地方。请注意,这也会选择this-icn-class
之类的东西,因为它只检查icn-
而不管前面的字符是什么。