本文主要包含CSS,hack,兼容一览等相关知识,佚名  希望在学习及工作中可以帮助到您
  
  不同的浏览器对CSS的解释都有一点出入,特别是padding, line-height这些要细微控制的地方,下面的hack基本可以解决这个问题: 
• 在属性前加下划线(_),那么此属性只会被IE6解释
• 在属性前加星号(*),此属性只会被IE7解释
• 在属性值后面加"\9",表示此属性只会被IE8解释
各浏览器CSS hack兼容表:
    
        
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>演示: 区分 IE6 / IE7 /IE8 /Firefox</title> </head> <style type="text/css" media="screen"> p.ie{ height:60px;text-align:center;line-height:60px;border:1px dashed #bbb;background:#f7f7f7; color:blue; color:brown\9; +color:red; _color:green; } </style> <body style="width:500px;margin:0 auto;"> <p class="ie"> <span style="display:block;display:none\9;">嘿嘿,小子竟然也用Firefox,蓝色文字。</span> <!--[if IE 8]>不错不错,挺先进的嘛,使用IE8呢!文字是褐色的。<![endif]--> <!--[if IE 7]>你,IE7,红色文字!<![endif]--> <!--[if IE 6]>孩子,虽然显示的是绿色文字,不过,IE6可不是好东西呢!<![endif]--> </p> </body> </html>
提示:您可以先修
 
 
 
 • 在属性前加下划线(_),那么此属性只会被IE6解释
• 在属性前加星号(*),此属性只会被IE7解释
• 在属性值后面加"\9",表示此属性只会被IE8解释
各浏览器CSS hack兼容表:
| IE6 | IE7 | IE8 | Firefox | Chrome | Safari | |
| !important | Y | Y | ||||
| _ | Y | |||||
| * | Y | Y | ||||
| *+ | Y | |||||
| \9 | Y | Y | Y | |||
| \0 | Y | |||||
| nth-of-type(1) | Y | Y | 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>演示: 区分 IE6 / IE7 /IE8 /Firefox</title> </head> <style type="text/css" media="screen"> p.ie{ height:60px;text-align:center;line-height:60px;border:1px dashed #bbb;background:#f7f7f7; color:blue; color:brown\9; +color:red; _color:green; } </style> <body style="width:500px;margin:0 auto;"> <p class="ie"> <span style="display:block;display:none\9;">嘿嘿,小子竟然也用Firefox,蓝色文字。</span> <!--[if IE 8]>不错不错,挺先进的嘛,使用IE8呢!文字是褐色的。<![endif]--> <!--[if IE 7]>你,IE7,红色文字!<![endif]--> <!--[if IE 6]>孩子,虽然显示的是绿色文字,不过,IE6可不是好东西呢!<![endif]--> </p> </body> </html>
提示:您可以先修

