在我的 HTML 中,
<div class="container"></div><div 类="容器"></div><div 类="容器"></div><div 类="容器"></div>..........................................在上面的 HTML 中,我有 container 类.在我的 CSS 中,我需要添加一些样式到 .container:nth-child(3,4,5,6,..等等).意味着我需要应用除 1 和 2 之外的所有 nth-child.
:nth-child() 不适用于类,它会查找元素本身.您需要通过包装器包装 .container div 并使用以下内容:
.wrapper div:nth-child(n+3) {/* 把你的样式放在这里... *
:target 为空时的 CSS 选择器CSS selector when :target empty(:target 为空时的 CSS 选择器)
CSS 直接后代 (>) 在选择性方面没有任何价值Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在选择性方面没有任何价值吗?)
使用 querySelectorAll().方法返回的结果是否有序?Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的结果是否有序?)
Safari 错误:当使用 JS 删除项目时,first-child 不更Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 错误:当使用 JS 删除项目时,first-child 不更新
nth-子 CSS 选择器nth-Child CSS selectors(nth-子 CSS 选择器)
对多个 HTML 标签使用相同的 ID?Using same ID for multiple HTML tags?(对多个 HTML 标签使用相同的 ID?)