NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
[TOC] # 属性选择器 ![](https://img.kancloud.cn/ce/9e/ce9e364c544c31c18c2f54f1f73f9b03_1232x618.png) | ![](https://img.kancloud.cn/38/ca/38caf4a785199ead13fc03876d7535cf_503x304.png) | ![](https://img.kancloud.cn/29/d7/29d73a3bcf2308f83dd208378ed56ce5_599x774.png) | | --- | --- | # 结构伪类选择器 ![](https://img.kancloud.cn/d1/8b/d18baa937d14e69d84dfbb83e419ea24_1103x593.png) ![](https://img.kancloud.cn/e1/d5/e1d5f71d135196ce1277fdd1b62d66a5_1334x792.png) ## nth-child(n) 【匹配父元素】 ![](https://img.kancloud.cn/3a/e6/3ae6491c4719846a753d103ae96c6ca1_495x138.png) ![](https://img.kancloud.cn/63/18/6318b09ff1b91b5972a44f7b41f2af11_845x373.png) nth-child(n) 列表 隔行背景颜色 ![](https://img.kancloud.cn/9a/48/9a48eed0a8d2009335220851aa9697d3_1022x390.png) nth-child(n) 公式 ![](https://img.kancloud.cn/73/dd/73dd6ee5bc5998aec1dbb59bb3049555_1302x768.png) | 奇数偶数![](https://img.kancloud.cn/e3/74/e3749c54490db3348ae9bdf5f2b3fdb5_590x392.png) | 倍数![](https://img.kancloud.cn/db/5a/db5a5ab307abb62eb0615d21aeb7d1f2_1013x500.png) | | --- | --- | ## 总结: :nth-child(n) 选择 父元素里面的第n个孩子,它不管里面的孩子是否同一种类型 ## nth-of-type【of-type选择指定类型的】 ![](https://img.kancloud.cn/e0/c7/e0c77ec0a1f25541287a070534249c59_450x138.png) 实验![](https://img.kancloud.cn/f6/c3/f6c330670a599fa793e51b67d2f63e73_625x504.png) # 虚伪元素选择器 ![](https://img.kancloud.cn/e6/6f/e66f7c9a42b51767ceb29fa168ce91f3_1216x345.png) ## 注意: ●before和after必须有content 属性 ●before在内容的前面, after 在内容的后面 ●before和after创建一个元素,但是属于行内元素。 ●因为在dom里面看不见刚才创建的元素,所以我们称为伪元素 ●伪元素和标签选择器一样,权重为1 ## 伪类选择器实验 | ![](https://img.kancloud.cn/d8/a8/d8a837ff0abd361e13e5e5402f40daa3_707x749.png) | ![](https://img.kancloud.cn/1f/d7/1fd7391bff9d318610e1471347121cf2_519x290.png) | | --- | --- | ## 伪类选择器与字体图标 在标签样式直接写content(里面写内容),html里面不用动直接引用 ![](https://img.kancloud.cn/9e/ae/9eaeb7894ba2ce8b2fb2550efc394d2d_622x279.png)