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 基础篇(5):覆盖width: !important #11

Open
rhymecoding opened this issue Jul 30, 2018 · 1 comment
Open

CSS 基础篇(5):覆盖width: !important #11

rhymecoding opened this issue Jul 30, 2018 · 1 comment
Labels

Comments

@rhymecoding
Copy link

!important拥有最高的权限,比如下面是别人CSS,如何覆盖width呢?

#div {
  width: 100px !important;
}

除了使用更高权重的选择器+!important,还可以使用max-widthmin-width

#div {
  min-width: 200px;
  max-width: 200px;
}
@shiiiiiiji shiiiiiiji added this to the Contributions milestone Jul 30, 2018
@Yatoo2018
Copy link

补充一个:
important这个尽量不要用,因为他会破坏层叠样式表权重的计算规则,如果写了多条!important导致样式很难排查问题。

另外,我补充了一个文章:
https://yatoo2018.github.io/Yatoo/2018/07/31/CSS-Cascade.html
没有加评论系统,先凑合看下

@shiiiiiiji shiiiiiiji removed this from the Contributions milestone Aug 8, 2018
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

3 participants