CSS Hack是在标准CSS没办法兼容各浏览器显示效果时才会用上的补救方法,在各浏览器厂商解析CSS没有达成一致前,我们只能用这样的方法来完成这样的任务.

1、浏览器特定的选择器
当你想在一个浏览器里改变样式而不像在其他浏览器中改变时,这些选择器很有用。
IE6以下
   *html{}

IE 7 以下
*:first-child+html {} * html {}

只对IE 7
*:first-child+html {}

只对IE 7 和现代浏览器
html>body {}

只对现代浏览器(非IE 7)
html>/**/body {}

Firefox:

*:lang(lang) selector { property:value !important; }
用伪类lang(语言)再加上!important进行定义的话,目前只有Firefox可以识别.

Opera

@media all and (min-width: 0px){ selector { property:value; } }
利用特殊继承法进行定义的话,目前只有Opera可以识别.

Safari

html[xmlns*=”"] body:last-child {}
要使用这些选择器,请在样式前写下这些代码。例如:
#content-box {
width: 300px;
height: 150px;
}
* html #content-box {
width: 250px;
}
/* 重写上面的代码并且把宽度改为250PX
在IE6以下版本中适用。 */

selector:empty { property:value !important; }
用伪类empty再加上!important进行定义的话,目前只有Safari可以识别.

以上的Hack并不完整,大家一起补充.

兼容一览图地址:http://centricle.com/ref/css/filters/
CSS hacks汇总

相关文章:

  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-09-26
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2021-09-08
  • 2022-01-01
  • 2022-01-24
  • 2021-09-09
  • 2021-10-22
  • 2021-07-10
  • 2021-09-27
相关资源
相似解决方案