【发布时间】:2019-05-15 18:37:34
【问题描述】:
我需要通过 CSS 为每四个可选元素制作背景颜色。我怎样才能做到这一点?
我找到了替代两个元素的解决方案,但我不明白如何在四个元素中制作它。 每两个元素都在这里找到:-
【问题讨论】:
标签: css css-selectors
我需要通过 CSS 为每四个可选元素制作背景颜色。我怎样才能做到这一点?
我找到了替代两个元素的解决方案,但我不明白如何在四个元素中制作它。 每两个元素都在这里找到:-
【问题讨论】:
标签: css css-selectors
li:nth-of-type(4n) {
color: red;
}
更新:选择四人组
li:nth-of-type(8n+1),
li:nth-of-type(8n+2),
li:nth-of-type(8n+3),
li:nth-of-type(8n+4)
{
color: red;
}
li:nth-of-type(8n+5),
li:nth-of-type(8n+6),
li:nth-of-type(8n+7),
li:nth-of-type(8n+8)
{
color: blue;
}
看到这支笔[更新] https://codepen.io/prny/pen/GarEMK
更多关于这里的 W3S https://www.w3schools.com/cssref/sel_nth-of-type.asp
【讨论】: