From a0571772858c5dba35f375df723e8b0dd1d4aed7 Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Sun, 8 Aug 2021 13:57:13 -0700 Subject: [PATCH] doc: multiple selector section --- source/_posts/CSS.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/_posts/CSS.md b/source/_posts/CSS.md index cd1a6cd..269d65d 100644 --- a/source/_posts/CSS.md +++ b/source/_posts/CSS.md @@ -96,4 +96,18 @@ cursor: pointer; /* can set new pointer icon, usually a "hand" */ | :first-child | 第一个出现在另一个元素中的元素 | | :nth-child(N) | 适用于给定父结点的第n个子结点 | -还有很多这样的伪类,但是上面这几个伪类是常用的 \ No newline at end of file +还有很多这样的伪类,但是上面这几个伪类是常用的 + +## 多个选择器 +如果我们的CSS选择器里有多个选择器,那哪个选择器会赢? +每个CSS选择器都有一定的特异性。 +特异性决定了哪个冲突规则获胜。 +更具体的规则凌驾于更不具体的规则之上。 + +例如: +```css +a { color: red; } /* 不特定 */ +a.some-link { color: white; } /* 有些特定的 */ +a#my-link { color: blue; } /* 非常具体的 */ +``` +即使稍后出现不太具体的规则,也是如此。 \ No newline at end of file