【发布时间】:2013-03-12 05:40:55
【问题描述】:
让我们看看下面的 HTML 块,
在这里,在上面的块中,我们为每个 div 使用了类。
我们也可以用CSS selectors替换classes
.first{
/* some styles */
}
.first:nth-child(1){
/* some styles */
}
.first div:nth-child(1){
/* some styles */
}
上面的 CSS chunk 也可以满足我们的要求
最佳做法是什么?说明我们可以使用selectors和classes的条件
谢谢:)
【问题讨论】:
-
使用类首先想到的好处是,当您插入一个新元素时,您必须重构所有后续的
:nth-child()选择器。
标签: html css coding-style