結構性偽類選擇器與倒序版的

2021-10-09 16:11:14 字數 743 閱讀 7785

結構性偽類選擇器 (style)

1:a標籤中第乙個兒子b採用此樣式

a b:first-child

2:a標籤中最後乙個兒子b採用此樣式

a b:flast-child

3:a標籤中唯一的乙個兒子b採用此樣式

a b:only-child

4:a標籤中第三個兒子b採用此樣式

a b:nth-child(3)

5:a標籤中奇數兒子b採用此樣式

a b:fnth-child(odd)

6:a標籤中偶數兒子b採用此樣式

a b:fnth-child(even)

結構性偽類選擇器(倒序)

1:從下往上數a標籤的第奇數個兒子b採用此樣式

a b:nth-last-child(odd)

2:從下往上數a標籤的第偶數數個兒子b採用此樣式

a b:nth-last-child(even)

3:從下往上數a標籤的第4個兒子b採用此樣式

a b:nth-last-child(4)

4:從下往上數a標籤的第乙個兒子b採用此樣式

a b:first-child

結構性偽類選擇器

doctype html html lang en head title 結構性偽類選擇器 title meta charset utf 8 meta name viewport content width device width,initial scale 1 style a hover fir...

結構性偽類選擇器 root

root選擇器,從字面上我們就可以很清楚的理解是根選擇器,他的意思就是匹配元素e所在文件的根元素。在html文件中,根元素始終是。示例演示 通過 root 選擇器設定背景顏色 html root選擇器的演示 css root演示結果 root 選擇器等同於元素,簡單點說 root html 得到的效...

結構性偽類選擇器 nth child n

經驗與技巧 當 nth child n 選擇器中的n為乙個表示式時,其中n是從0開始計算,當表示式的值為0或小於0的時候,不選擇任何匹配的元素。如下表所示 案例演示 通過 nth child n 選擇器,並且引數使用表示式 2n 將偶數行列表背景色設定為橙色。html item1 item2 ite...