CSS的作用:nth-child(n)选择器
使用CSS:nth-child(n)选择器来设置每个<p>元素的样式,这些元素是使用CSS父元素的第二个子元素。您可以尝试运行以下代码来实现:nth-child(n)选择器
示例
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-child(4) {
background: orange;
color: white;
}
</style>
</head>
<body>
<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>
</body>
</html>热门推荐
10 岁岁祝福语简短独特
11 小爱心卡片祝福语简短
12 女性的生日祝福语简短
13 家人毕业祝福语简短励志
14 老师简短祝福语有哪些
15 校庆结尾文案祝福语简短
16 婚礼父母在家祝福语简短
17 冬季最美的祝福语简短
18 哥哥结婚的祝福语简短