CSS: nth-child()选择前几个元素

原文连接 前言 渲染列表时,须要设置前3个元素的margin-top值与其余的不一样。css 使用 :nth-child(-n+3){ margin-top: 12px; } 扩展 选择前几个元素html /*【负方向范围】选择第1个到第6个 */ :nth-child(-n+6){}   从第几个开始选择 /*【正方向范围】选择从第6个开始的 */ :nth-child(n+6){}
相关文章
相关标签/搜索