企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
[TOC] #### 子代选择: 同级兄弟之间选择: 正着选: div:nth-child(3) 反着选:div:nth-last-child(3) ~~~ <style> div:nth-child(3){ color: red; } div:not(:last-child){ color: red; } </style> </head> <body> <div class="parent"> <div>1</div> <div>1</div> <div>1</div> <div>1</div> </div> </body> ~~~ x:nth-child(3){ } x:相同的元素名称 ### 同级关系的选择器 ~~~ 1. p:first-child{ } 2. p:last-child{} 3. .父类名>p:not(.子类的其中一个类名){} 列如: <div class="parent"> <P>1</p> <P class="two">1</p> <P>1</p> <P>1</p> </div> ~~~