html - 田野上的第一个 child

标签 html css

我在名为 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/

相关文章:

css - 如何为选定的选项卡提供矩形样式样式 css,如下面的屏幕截图所示?

html - 聊天框固定在最大宽度时不会扩展 <p>

css - 自定义 Azure API 管理开发人员门户

html - 内联CSS是否继承?

javascript - GUI 中令人惊叹的聊天机器人查询和回复

javascript - 窗口高度不变

javascript - div 位置绝对...溢出-y :auto and then vertical scrollbar covers some of the content

javascript - 滚动 div 元素时防止页面滚动

javascript - 仅在 IE 7 中不提交表单

css - 选择所选单选按钮的包含 div