伪类和伪元素 发表于 2022-08-10 | 更新于: 2025-08-19 | 字数统计: 115 参考https://developer.mozilla.org/zh-CN/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements 伪类伪类是选择器的一种,用于选择处于特定状态的元素,开头为冒号 1:pseudo-class-name 例子: :first-child :last-child :only-child :invalid 表示任意内容未通过验证的<input>或其他<form>元素 :hover :focus 伪元素伪元素像新的元素,开头为双冒号 1::pseudo-element-name 例子: ::first-line ::before ::after