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

CSS定义的权重?优先级? #64

Open
GGXXMM opened this issue Nov 16, 2020 · 0 comments
Open

CSS定义的权重?优先级? #64

GGXXMM opened this issue Nov 16, 2020 · 0 comments
Labels

Comments

@GGXXMM
Copy link
Owner

GGXXMM commented Nov 16, 2020

一、CSS定义的权重

以下是权重的规则:标签的权重为1,class的权重为10,id的权重为100

 /*权重为1*/
  div{
  }
  /*权重为10*/
  .class1{
  }
  /*权重为100*/
  #id1{
  }
  /*权重为100+1=101*/
  #id1 div{
  }
  /*权重为10+1=11*/
  .class1 div{
  }

二、优先级

相同权重下:内联(标签内部) > 嵌入(当前文件<style>) > 外部(外部文件)
!important > id > class > tag

!important优先级高于内联

@GGXXMM GGXXMM added the css label Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant