gpt4 book ai didi

html - 第 n 个子选择器在 css 中不起作用(?)

转载 作者:可可西里 更新时间:2023-11-01 13:03:14 25 4
gpt4 key购买 nike

<分区>

所以我想用nth-child选择器让第一段变成红色。这是我的代码:

<!DOCTYPE html>
<html>
<head>
<style>
p:nth-child(1) {
background: #ff0000;
}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>I want this paragraph to be red.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
</body>
</html>

但结果是 0 段红色...我不明白我做错了什么。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com