sms*_*omb 2 html css css-selectors css3
我正在使用css nth-child选择器尝试为无序列表中的每个第6和第7个元素添加20px的边距.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
X X X X X X X X
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经通过使用两个单独的css选择器完成了这个:
li:nth-child(5n+6){}
li:nth-child(5n+7){}
Run Code Online (Sandbox Code Playgroud)
有没有办法只使用一个n-child公式来完成这种模式?
不可以.基本功能y = ax+b将整数值映射x到均匀间隔的值y.您的目标元素间距不均匀.
因此,您必须使用li:nth-child(5n+6),li:nth-child(5n+7),没有可能的简化.