现在的位置: 首页 > 综合 > 正文

CSS兼容IE6,IE7,FIREFOX的hack收集

2018年05月15日 ⁄ 综合 ⁄ 共 542字 ⁄ 字号 评论关闭

 CSS兼容IE6,IE7,FIREFOX的hack收集
一种,是CSS HACK的方法注意顺序。
程序代码 程序代码
height:20px; /*For Firefox*/
*height:25px; /*For IE7 & IE6*/
_height:20px; /*For IE6*/

下面是针对id或者是自定义的样式也属于CSS HACK,不过没有上面这样简洁。
程序代码 程序代码
#example { color: #333; } /* Moz */
* html #example { color: #666; } /* IE6 */
*+html #example { color: #999; } /* IE7 */

第二种是使用IE专用的条件注释,也就是在引用或者导入css的时候使用“注释判断”来兼容。
程序代码 程序代码
<!--其他浏览器 -->
<link rel="stylesheet" type="text/css" href="css.css" />
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]-->
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]-->

抱歉!评论已关闭.