文章详情页
css - 关于nth-child()的问题
问题描述
span:nth-child(-n+3)匹配前三个子元素中的span元素为什么是匹配前3个元素??如果n是0开始的话,不应该是n+3吗?
问题解答
回答1:span:nth-child(n+3) 感觉是匹配的从第三个往后的所有 span 元素
n 应该是从 0,1,2,…… 加上负号才能保证 nth-chlid(里面的数字小于等于三)
回答2:Example:
-n+6 / represents the first 6 elements of the list /
The values of A and B can be negative, but only the positive results of An+B, >for n ≥ 0, are used.
你可以这样理解,n是从0开始计数(0,1,2...)所以(-n+6) => (6,5,4,3,2,1)所以是前六个上面的引用已经说了,只有正数会被使用。
标签:
CSS
相关文章:
1. python相关问题求解决,有偿2. javascript - input输入框触发change事件后,外部元素会被选中3. python - 用__call__ 实现装饰器功能4. javascript - 把字符串日期转换成一般时间格式后,发现小于10的数字不会自动添加0在前面,如下5. javascript - 在sublime中如何给.vue文件注释?6. javascript - js判断一个数组是否重复7. python - 请问用cxfreeze打包的可执行程序能反编译出源码么?8. javascript - vue2.0中router.repalce跟router.push有什么区别,二者的应用场景是会有怎样的区别?9. javascript - 这种上传图片预览怎么做?10. javascript - prismplayer播放器全屏问题
排行榜