html中小于和大于怎么判断,html – CSS nth-child大于和小于
:nth-??child()不適用于類,它查找元素本身。您需要使用包裝器來包裝.container div,并使用以下內容:
.wrapper div:nth-child(n+3) {
/* put your styles here... */
}
澄清:nth-??child()
使用.container:nth-??child(n 3)可能會也可能不工作。因為:nth-??child()偽類表示與選擇器匹配的第n個子元素(在這種情況下為.container)。
如果.container元素不是其父項的第n個子元素,則不會被選中。
The :nth-child(an+b) pseudo-class notation represents an element
that has an+b-1 siblings before it in the document tree, for any
positive integer or zero value of n, and has a parent element.
考慮這個例子:
1st2nd3rd4th5th6th7th8th9th在這種情況下,.container:nth-??child(2)將不會選擇第二個div.container元素(具有第5個內容)。因為該元素不是其父項的第二個子節點,而是父節點的子樹中。
另外,.container:nth-??child(n3)將會選擇所有的div.container元素,因為n從父的子樹中的第一個元素開始為0,第一個div.container是其父代的第四個子節點。
n starts from 0
n = 0: (0 + 3) = 3 => 3rd element
n = 1: (1 + 3) = 4 => 4th element
n = 2: (2 + 3) = 5 => 5th element
...
因此,div.container:nth-??child(n 3)表示匹配div.container選擇器的所有第3,第4,第5,…子元素。
總結
以上是生活随笔為你收集整理的html中小于和大于怎么判断,html – CSS nth-child大于和小于的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mvc html.displayfor,
- 下一篇: html制作主体部分,html – 使用