Skip to content

Instantly share code, notes, and snippets.

@mqxu
Created November 3, 2019 12:10
Show Gist options
  • Save mqxu/7a49a09b705b08edece1ab306e7a6c9b to your computer and use it in GitHub Desktop.
Save mqxu/7a49a09b705b08edece1ab306e7a6c9b to your computer and use it in GitHub Desktop.
【iCSS:布局】使用:nth-child()选择指定元素
<div class="bruce flex-ct-x">
<ul class="specified-scope">
<li>10001</li>
<li>10002</li>
<li>10003</li>
<li>10004</li>
<li>10005</li>
<li>10006</li>
<li>10007</li>
<li>10008</li>
<li>10009</li>
<li>10010</li>
</ul>
</div>
.specified-scope {
width: 300px;
li {
padding: 0 20px;
height: 40px;
line-height: 40px;
color: #fff;
&:nth-child(odd) {
background-color: #f66;
}
&:nth-child(even) {
background-color: #66f;
}
&:nth-child(n+6):nth-child(-n+10) {
background-color: #3c9;
}
}
}
<link href="https://yangzw.vip/static/css/reset.css" rel="stylesheet" />
<link href="https://yangzw.vip/static/css/main.css" rel="stylesheet" />
<link href="https://yangzw.vip/static/css/theme.scss" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment