Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

选择器及样式优先级 #13

Open
lxinr opened this issue Apr 23, 2019 · 0 comments
Open

选择器及样式优先级 #13

lxinr opened this issue Apr 23, 2019 · 0 comments

Comments

@lxinr
Copy link
Owner

lxinr commented Apr 23, 2019

选择器

主要分成三种等级

1、id选择器,权重100

2、类选择器(class)、属性选择器(如[type="radio"])、伪类选择器(如:hover),权重10

3、标签选择器(如h2)、伪元素(如::after),权重1

最终的优先级是累积起来计算的

样式优先级

除了选择器的权重之外,影响样式还有另外两个特殊的规则:!important内联样式

!important它的层级最高,会覆盖任何其他声明

因此最终的样式优先级是:!important > 内联样式 > 选择器权重

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant