.mac{margin-left:auto; margin-right:auto;}
.table{.mac; color:red;}
我希望能够做到这一点,但我不明白为什么我需要这样做:
.table{margin-left:auto; margin-right:auto; color:red;}
我知道我可以做的 table :
<table class="table mac">
或者直接输入 .table{margin-left:auto;右边距; color;}
和上面一样,但这似乎是多余的。
有没有什么方法可以完成我在第一条语句中想要完成的事情,是否有一些我不知道的特殊语法来完成这项工作?
最佳答案
您可以在同一行使用逗号组合多个 CSS 选择器:
.mac, .table
{
margin-left:auto;
margin-right:auto;
}
.table
{
color:red;
}
关于css - 如何将 css 类放在 css 类中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1941067/