
要使用 CSS 为作为其父级的第二个子级的每个
元素设置样式,请使用 CSS :nth-child(n) 选择器。
示例 h2>
您可以尝试运行以下代码来实现:nth-child(n)选择器
Live Demo
<style>
p:nth-child(4) {
background: orange;
color: white;
}
</style>
<p>This is demo text 1.</p>
<p>This is demo text 2.</p>
<p>This is demo text 3.</p>
<p>This is demo text 4.</p>
<p>This is demo text 5.</p>
<p>This is demo text 6.</p>
前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!










