虽然说使用css hack来解决页面兼容性bug并不是个好办法,但是有时候这些hack还是用的着的,比如你接受了一个二手或是三手的遗留界面,杂乱无章的css代码,只在某个浏览器下有兼容bug,而且需要短时间内处理。

    下面一段代码可以让你很快利用css来为特定的浏览器指定样式。不多赘述,看码即懂:

属性过滤:
_height:10px; /* IE6支持 */
*height:10px; /* IE6、IE7支持 */
height:10px\0/; /* IE8支持 */


选择器过滤:

/*针对IE6*/
* html #nav{  margin:12px;  }


/*针对IE7*/
*+html #nav{  margin:11px; }



/*针对Firefox*/
@-moz-document url-prefix() {
    #nav{ width:200px; }
}
IE7、Firefox共用
height: 100px !important(优先级)


/*针对Safari & Chrome* 360 搜狗/
@media screen and (-webkit-min-device-pixel-ratio:0) {
    #nav{ width:300px; }
}


/*针对Opera*/
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {
    #nav{ width:400px; }
}

 

相关文章:

  • 2021-07-13
  • 2021-10-05
  • 2021-09-03
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-14
  • 2021-07-06
  • 2021-08-11
  • 2022-03-08
  • 2021-11-29
  • 2021-08-17
相关资源
相似解决方案