background: gold; } input:out-of-range+h2::after { /* :out-of-range 伪类 */ /* ::after 伪元素 只能有一个*/ /* 超出input的输入范围h2拼接 超出范围的文字 */ content: ‘超出范围’; color: red; } 请输入数字 结果 : 伪类伪元素位置 Document 伪类、伪元素 DOM操作 Document 第一个第二个第三个第四个第五个 伪类伪元素优缺点对比 Document