我想知道何时以及如何对重复的属性进行分类。考虑结构之间的可读性、代码性能、优缺点。假设我有两个 CSS 代码:
第一个代码:
.a {
text-align: center;
font-size: 1em;
background-color: red;
}
.b {
text-align: center;
font-size: 1em;
background-color: green;
}
.c {
text-align: center;
font-size: 2em;
background-color: blue;
}
.d {
background-color: blue;
}
第二个代码:
.a,
.b,
.c {
text-align: center;
}
.a,
.b {
font-size: 1em;
}
.c,
.d {
background-color: blue;
}
.a {
background-color: red;
}
.a {
background-color: green;
}
.c {
font-size: 2em;
}
那么哪一个是更好的家伙,非常感谢之前:)