是否有可能使一个CSS规则结合两个或更多其他CSS规则? [英] Is it possible make a CSS rule that combines two or more other CSS rules?

查看:156
本文介绍了是否有可能使一个CSS规则结合两个或更多其他CSS规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

.strong {
        font-weight: bold;
}
.italicized {
        font-style: italic;
}
.strong_and_italicized {
        .strong;
        .italicized;
}

我问,因为我正在处理一些jQuery操作一些DOM对象已经从jquery ui主题css文件分配了多个不同的类。在我看来,将多个类组合成一个类会更容易,然后我可以在尝试选择DOM对象时在JavaScript代码中引用该类。

I ask because I'm working on some jquery that is manipulating some DOM objects that have been assigned multiple different classes from the jquery ui theme css file. It seems to me it would be much easier to combine the multiple classes into one class and then I could just refer to that class in the javascript code when trying to select the DOM object.

推荐答案

将CSS类合并成一个类似于我知道的唯一方法是使用一个CSS预处理器,如 LESS SASS

The only way to combine CSS classes into one like that, that I know of, is to use a CSS pre-processor like LESS or SASS.

如果您不想使用它,恐怕你必须分别分配这两个类。

If you don't want to use that, I'm afraid you have to assign both classes separately.

这篇关于是否有可能使一个CSS规则结合两个或更多其他CSS规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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