我在名为 myform 的表单标签中有 2 个字段集
我正试图到达第一个字段集。现在在字段集之前还有其他 div 和 p 标签。 我在第一个和最后一个 fieldset 上尝试这个
<myform>
<div></div
<p></p>
<fieldset></fieldset>
<div></div>
<fieldset></fieldset>
</myform>
#myform fieldset{
// all round styles for the fieldset
}
#myform:first-child fieldset{
// specific to the first field set
}
#myform:last-child fieldset{
specific to the last filedset
}
最佳答案
您的 html 不正确。 <myform></myform>
应该是 <form id="myform"></form>
正确的选择器是#myform fieldset:first-of-type
This page是关于 css 伪类如何工作的很好的引用
关于html - 田野上的第一个 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6751413/