!important的用法

如果写成:a{color:teal !important},IE6和其它高版本浏览器都认识,(IE6虽然不认识!important,但它还是能够认识!important之前的color:teal这个属性的,
如果写成a{color:red;color:teal !important},则所有浏览器也都把文字的颜色设置为teal这个颜色。
但是,如果把刚才的CSS样式改为a{color:teal !important;color:red},则在火狐和IE6+的浏览器里则以color:teal为准,
因为他们认识!important,则它的优化级高,所以采用color:teal。
而IE6呢,尤由它不认识!important,但能认识color:teal这个属性,所以color:teal和color:red都要采用,
但后来定义的颜色会覆盖 前面定义的颜色,也就是说color:red会覆盖color:teal,
所以我们在IE6里我看到的应该是red这个色。

<div style=" min-height:100px !important; height:auto!important; height:100px; width:300px; ">

 

posted on 2010-06-28 15:47  lovening  阅读(9604)  评论(1编辑  收藏  举报