css_sduty/06_CSS复合选择器/12_伪类选择器_否定伪类 copy.html
zhuyijun 96aa6f59ba feat(css): 新增选择器
1、伪类选择器
2、伪元素选择器
3、选择器优先级
2024-08-25 14:09:40 +08:00

34 lines
946 B
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>12_伪类选择器_否定伪类</title>
<style>
/* 选择的是div的儿子p元素但是排除类名为fail的元素 */
/* div>p:not(.fail) {
color: red;
} */
/* 选择的是div的儿子p元素但是要排除title属性以“你要加油”开头的*/
/* div>p:not([title^="你要加油"]) {
color: red;
} */
div>p:not(:first-child) {
color: red;
}
</style>
</head>
<body>
<div>
<p>张三: 98分</p>
<p>李四: 88分</p>
<p>王五: 78分</p>
<p>赵六: 68分</p>
<p class="fail" title="你要加油啊! 孙七">孙七: 58分</p>
<p class="fail" title="你要加油啊! 老八">老八: 48分</p>
</div>
</body>
</html>