We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

CSS 虛擬類別(pseudo-class)的元素,在特殊狀態下被選取的話,會作為關鍵字被加到選擇器裡面。例如 :hover 會讓用戶的滑鼠停在某個元素的時候,套用指定選擇器的樣式。

虛擬類別與 pseudo-elements 能讓你不只能給文件樹(document tree)本身的相關內容套用樣式,還能給諸如瀏覽歷史(:visited)、內容的狀態(:checked)、還有滑鼠的位置(像 :hover 就能讓偵測滑鼠是否在元件上)之類的外部相關因素套用樣式。


selector:pseudo-class {
  property: value;



規範 狀態 註解
Fullscreen API Living Standard 定義 :fullscreen
HTML Living Standard Living Standard HTML5 並沒有改變。
Selectors Level 4 Working Draft 定義 :any-link, :local-link, :scope, :active-drop-target, :valid-drop-target, :invalid-drop-target, :current, :past, :future, :placeholder-shown, :user-error, :blank, :nth-match(), :nth-last-match(), :nth-column(), :nth-last-column(), and :matches().
沒有針對 Selectors Level 3HTML5 虛擬類別的重大更改(though semantic meaning not taken over)
HTML5 Recommendation 定義以下 HTML context 的語意含義: :link, :visited, :active, :enabled, :disabled, :checked, and :indeterminate.
定義 :default, :valid, :invalid, :in-range, :out-of-range, :required, :optional, :read-only, :read-write, and :dir().
CSS Basic User Interface Module Level 3 Candidate Recommendation 定義 :default, :valid, :invalid, :in-range, :out-of-range, :required, :optional, :read-only, :read-write,但沒有語意含義的定義。
Selectors Level 3 Recommendation 定義 :target, :root, :nth-child(), :nth-last-of-child(), :nth-of-type(), :nth-last-of-type(), :last-child, :first-of-type, :last-of-type, :only-child, :only-of-type, :empty, :not().
定義 :enabled, :disabled, :checked, :indeterminate 的語法,但沒有語意含義的定義。
CSS Level 2 (Revision 1) 並沒有明顯改變。
CSS Level 2 (Revision 1) Recommendation 定義 :lang(), :first-child, :hover, :focus.
CSS Level 1 並沒有明顯改變。
CSS Level 1 Recommendation 定義 :link, :visited, :active,但沒有語意含義的定義。



此頁面的貢獻者: iigmir
最近更新: iigmir,