HTML5---H5---CSS常用的選擇器

屬性:

element1~element2 p~ul 選擇前面有 <p> 元素的每個 <ul> 元素。 3
[attribute^=value] a[src^="https"] 選擇其 src 屬性值以 "https" 開頭的每個 <a> 元素。 3
[attribute$=value] a[src$=".pdf"] 選擇其 src 屬性以 ".pdf" 結尾的所有 <a> 元素。 3
[attribute*=value] a[src*="abc"] 選擇其 src 屬性中包含 "abc" 子串的每個 <a> 元素。 3
:first-of-type p:first-of-type 選擇屬於其父元素的首個 <p> 元素的每個 <p> 元素。 3
:last-of-type p:last-of-type 選擇屬於其父元素的最後 <p> 元素的每個 <p> 元素。 3
:only-of-type p:only-of-type 選擇屬於其父元素唯一的 <p> 元素的每個 <p> 元素。 3
:only-child p:only-child 選擇屬於其父元素的唯一子元素的每個 <p> 元素。 3
:nth-child(n) p:nth-child(2) 選擇屬於其父元素的第二個子元素的每個 <p> 元素。 3
:nth-last-child(n) p:nth-last-child(2) 同上,從最後一個子元素開始計數。 3
:nth-of-type(n) p:nth-of-type(2) 選擇屬於其父元素第二個 <p> 元素的每個 <p> 元素。 3
:nth-last-of-type(n) p:nth-last-of-type(2) 同上,但是從最後一個子元素開始計數。 3
:last-child p:last-child 選擇屬於其父元素最後一個子元素每個 <p> 元素。 3
:root :root 選擇文檔的根元素。 3
:empty p:empty 選擇沒有子元素的每個 <p> 元素(包括文本節點)。 3
:target #news:target 選擇當前活動的 #news 元素。 3
:enabled input:enabled 選擇每個啓用的 <input> 元素。 3
:disabled input:disabled 選擇每個禁用的 <input> 元素 3
:checked input:checked 選擇每個被選中的 <input> 元素。 3
:not(selector) :not(p) 選擇非 <p> 元素的每個元素。 3
::selection ::selection 選擇被用戶選取的元素部分。 3

發佈了78 篇原創文章 · 獲贊 20 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章