CSS:如何为尚未设置样式的所有<li>元素选择CSS?</li>

时间:2014-04-01 16:05:13

标签: css

所以我在我的列表(第一,第二,最后和最后一个奇怪的孩子)中标记了一些边缘情况,如下所示:

/* First and second elements */
li:first-child, li:first-child + li {
    ...
}

/* Last odd and last elements */
li:last-child {
    ...
}

/* CSS for second last list element, only when it's odd. */
li:nth-last-child(2):nth-child(odd) {
    ...
}

如何为所有剩余元素选择相同的CSS?你能指导我完成这个过程,所以我知道下一步该怎么做吗?

1 个答案:

答案 0 :(得分:2)

只需定义li个样式。由于特殊性规则,伪类会覆盖这些样式。