Select Items Using Negative nth-child
Use negative nth-child
in CSS to select items 1 through n.
li {
display: none;
}
/* select items 1 through 3 and display them */
li:nth-child(-n+3) {
display: block;
}
Or, since you’ve already learned a little about using :not()
, try:
/* select all items except the first 3 and display them */
li:not(:nth-child(-n+3)) {
display: block;
}
Demo
当前内容版权归 AllThingsSmitty 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 AllThingsSmitty .