如何指定:first-of-type
整个文档?
我想要设置<p>
HTML 的第一个样式,不管它位于何处(我不想写,section p:first-of-type
因为它可能位于不同HTML文档的其他位置).
p {
background:red;
}
p:first-of-type {
background:pink;
}
p:last-of-type {
background:yellow;
}
Run Code Online (Sandbox Code Playgroud)
<body>
<section>
<p>111</p>
<p>222</p>
<p>333</p>
</section>
<p>444</p>
<p>555</p>
</body>
Run Code Online (Sandbox Code Playgroud)