本系列笔记是基于【渡一教育】袁进老师的html+css基础课程而记录,仅作为个人记录以及阅读使用。
first-of-type 选中子元素中第一个指定类型的元素 表示一组兄弟元素中其类型的第一个元素
last-child
nth-child 选中指定的第几个子元素
eg: a:nth-child(5) /* 必须是a元素,必须是第五个子元素 */
nth-child(2n) nth-child(even) 选中第偶数个子元素
nth-child(2n+1) nth-child(odd) 选中第奇数个子元素
nth-child 按照个数来算。
nth-of-type 按照类型来计算,如果是class那么碰到不同类型的,单独一类,符合条件的选中。
first-letter 选中元素中的第一个字母
first-line 选中元素中第一行的文字
selection 选中被用户框选的文字,设置文字颜色、背景