如何将两个CSS类应用于单个div / span [英] How to apply two CSS classes to a single div/span

查看:135
本文介绍了如何将两个CSS类应用于单个div / span的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将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>

我试过,在我的case c2不会应用。

I tried and in my case c2 does not get applied. How can i apply both classes at once?

推荐答案

1)在类属性中使用多个类,用空格分隔( ref ):

1) Use multiple classes inside the class attribute, separated by whitespace (ref):

<a class="c1 c2">aa</a>

2)要定位包含所有指定类的元素,请使用此CSS选择器无空格)( ref ):

2) To target elements that contain all of the specified classes, use this CSS selector (no space) (ref):

.c1.c2 {
}

这篇关于如何将两个CSS类应用于单个div / span的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆