【发布时间】:2016-06-22 12:52:44
【问题描述】:
考虑以下代码(使用 sass):
#wrapper {
.switch-element:nth-child(even) {
}
.switch-element:nth-child(odd) {
}
}
<div class="wrapper">
<div class="normal-element">Element that needs to stay the same and should not be counted.</div>
<div class="normal-element">Element that needs to stay the same and should not be counted.</div>
<div class="switch-element">Element that needs to change and should be counted.</div>
<div class="normal-element">Element that needs to stay the same and should not be counted.</div>
<div class="switch-element">Element that needs to change and should be counted.</div>
</div>
这将计算包装器的每个子元素,使第一个元素“正常元素”、“1”(奇数)、第二个元素“正常元素”、“2”(偶数)、第三个元素“开关-元素”,“3”(奇数),第四个元素“正常元素”,“4”(偶数),第五个元素“开关元素”,“5”(奇数)。
我想让它忽略所有正常元素,只计算开关元素。使第一个开关元件为奇数,第二个开关元件为偶数。
有什么想法吗?
【问题讨论】:
标签: html css css-selectors selector