CSS中的通配符*用于类

随声附和 提交于 2020-05-08 16:32:05

问题:

I have these divs that I'm styling with .tocolor , but I also need the unique identifier 1,2,3,4 etc. so I'm adding that it as another class tocolor-1 . 我有这些div,我正在使用.tocolor ,但我还需要唯一标识符1,2,3,4等,所以我将它添加为另一个类tocolor-1

<div class="tocolor tocolor-1">   tocolor 1   </div>
<div class="tocolor tocolor-2">   tocolor 2   </div>
<div class="tocolor tocolor-3">   tocolor 3   </div>
<div class="tocolor tocolor-4">   tocolor 4   </div>

.tocolor{
  background: red;
}

Is there a way to have just 1 class tocolor-* . 有没有办法只有一个类tocolor-* I tried using a wildcard * as in this css, but it didn't work. 我试着在这个css中使用通配符* ,但它没有用。

.tocolor-*{
  background: red;
}

解决方案:

参考一: https://stackoom.com/question/LRPN/CSS中的通配符-用于类
参考二: https://oldbug.net/q/LRPN/wildcard-in-CSS-for-classes
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!