欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  什么是 !important
  
  CSS 中的 !important 规则用于增加样式的权重。
  
  !important 与优先级无关,但它与最终的结果直接相关,使用一个 !important 规则时,此声明将覆盖任何其他声明。
  
  实例
  
  #myid {
  
  background-color: blue;
  
  }
  
  .myclass {
  
  background-color: gray;
  
  }
  
  p {
  
  background-color: red !important;
  
  }
  
  以上实例中,尽管 ID 选择器和类选择器具有更高的优先级,但三个段落背景颜色都显示为红色,因为 !important 规则会覆盖 background-color 属性。

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/rumen/r64307.shtml