本文介绍了有没有办法在CSS中查询多个类的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何查询同时有两个类的元素
How do I query for an element that have two classes at the same time?
例如:
<div><span class="major minor">Test</span></div>
我想同时设置所有包含major和minor 。
I want to style all the spans that have "major" and "minor" classes at the same time.
推荐答案
以下应该可以做到:
span.major.minor { color: red; }
请注意,您必须小心使用Internet Explorer 6 - 它只会读取最后一个类的选择器。例如,它将不正确地应用上述规则到以下:
Note you have to be careful with this with Internet Explorer 6 - it will only read the last class of the selector. For example, it will incorrectly apply the rule above to the following:
<span class="minor">Test</span>
这篇关于有没有办法在CSS中查询多个类的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!