html - 我们可以在css中将两条规则组合成一条规则吗?
问题描述
我有两个senario
类从icn-
和中间开始。两者 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-
而不关心前面的字符。
推荐阅读
- php - 如果我想拥有一张伴随着其他图像的图像,我是否需要多个数据库表?
- amazon-web-services - 为什么 IAM“AmazonEC2FullAccess”策略不允许用户启动实例?
- javascript - 如何接受来自 Botkit 听到方法的多个值?
- apache-zookeeper - Zookeeper 中的 upconfig 和 downconfig 是什么?
- python - 无法使用 pip3 安装 eth-testrpc
- java - javax.validation 约束,给某个属性的属性添加违例
- docker - 将链接 docker 容器与网络混合
- python - GeoPandas .to_file 给出了错误的列?
- python - Python Pandas- Groupby 列获取 Pandas 数据框列中的两个峰值
- macros - 用户更改已编译宏中的变量