这篇翻译不完整。请帮忙从英语翻译这篇文章

CSS 伪类 是添加到选择器的关键字,指定要选择的元素的特殊状态。例如,:hover 可被用于在用户将鼠标悬停在按钮上时改变按钮的颜色。

div:hover {
  background-color: #F89B4D;
}

伪类连同伪元素一起,他们允许你不仅仅是根据文档DOM树中的内容对元素应用样式,而且还允许你根据诸如像导航历史这样的外部因素来应用样式(例如 :visited),同样的,可以根据内容的状态(例如在一些表单元素上的 :checked),或者鼠标的位置(例如 :hover 让你知道是否鼠标在一个元素上悬浮)来应用样式。

注意: 与伪类相反,pseudo-elements 可被用于为一个元素的 特定部分 应用样式。

语法

selector:pseudo-class {property: value;}

标准伪类索引

像普通的类一样,你可以在一个选择器中按需连用多个伪类。

规范

规范 状态 备注
Fullscreen API Living Standard Defined :fullscreen.
HTML Living Standard Living Standard No change from HTML5.
Selectors Level 4 Working Draft Defined :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().
No significant change for pseudo-classes defined in Selectors Level 3 and HTML5 (though semantic meaning not taken over).
HTML5 Recommendation Defined the semantic meaning, in the HTML context, of :link, :visited, :active, :enabled, :disabled, :checked, and :indeterminate.
Defined :default, :valid, :invalid, :in-range, :out-of-range, :required, :optional, :read-only, :read-write, and :dir().
CSS Basic User Interface Module Level 3 Proposed Recommendation Defined :default, :valid, :invalid, :in-range, :out-of-range, :required, :optional, :read-only, and :read-write, but without the associated semantic meaning.
Selectors Level 3 Recommendation Defined :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, and :not().
Defined the syntax of :enabled, :disabled, :checked, and :indeterminate, but without the associated semantic meaning.
No significant change for pseudo-classes defined in CSS Level 2 (Revision 1).
CSS Level 2 (Revision 1) Recommendation Defined :lang(), :first-child, :hover, and :focus.
No significant change for pseudo-classes defined in CSS Level 1.
CSS Level 1 Recommendation Defined :link, :visited, and :active, but without the associated semantic meaning.

参见

文档标签和贡献者

此页面的贡献者: RainSlide, Ende93, xgqfrms-GitHub, teoli, alimon
最后编辑者: RainSlide,