如何将两个CSS类应用于单个元素 [英] How to apply two CSS classes to a single element
本文介绍了如何将两个CSS类应用于单个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以将2个类应用于单个div或span或任何html元素吗?例如:
Can i apply 2 classes to a single div or span or any html element? For example:
<a class="c1" class="c2">aa</a>
我尝试过,但在我的情况下,c2没有得到应用.我如何一次申请两个课程?
I tried and in my case c2 does not get applied. How can i apply both classes at once?
推荐答案
1) Use multiple classes inside the class attribute, separated by whitespace (ref):
<a class="c1 c2">aa</a>
2)要定位包含所有指定类的元素,请使用此CSS选择器(没有空格)(
2) To target elements that contain all of the specified classes, use this CSS selector (no space) (ref):
.c1.c2 {
}
这篇关于如何将两个CSS类应用于单个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文