如何一次将样式应用于多个类? [英] How can I apply styles to multiple classes at once?

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

问题描述

我希望两个具有不同名称的类在 CSS 中具有相同的属性.我不想重复代码.

I want two classes with different names to have the same property in CSS. I don't want to repeat the code.

.abc {
   margin-left:20px;
}  
.xyz {
   margin-left:20px;
}

<a class="abc">Lorem</a>
<a class="xyz">Ipsum</a>

由于两个类都在做同样的事情,我应该能够将它合并为一个.我该怎么做?

Since both classes are doing the same thing, I should be able to merge it into one. How can I do that?

推荐答案

.abc, .xyz { margin-left: 20px; }

是您正在寻找的.

这篇关于如何一次将样式应用于多个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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