您现在的位置是:网站首页>前端技术

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

前端技术2020年11月12日4248浏览

简介用css选择器nth-child()来实现类似下面数字的效果刚开始想当然的以为li:nth-child(1,2,3)>i{color:darkcyan;}ofcourse,tooyongtoo&……

用css选择器 nth-child()来实现类似下面数字的效果

1605155398(1)

刚开始想当然的以为 li:nth-child(1,2,3)>i{color: darkcyan;}

 ofcourse,too yong too simple

正确的写法为:

li:nth-child(-n+3)>i{color: darkcyan;}

li:nth-child(-n+3)选择前三个li 元素


标签: css

0

评论文明上网,理性发言0条评论