1、css if hack条件语法
only ie
仅所有的win系统自带ie可识别
only ie 5.0
只有ie5.0可以识别
only ie 5.0+
ie5.0包换ie5.5都可以识别
only ie 6-
仅ie6可识别
only ie 6/+
ie6以及ie6以下的ie5.x都可识别
仅ie7可识别
only ie 7/+
ie7以及ie7以下的ie6、ie5.x都可识别
仅ie8可识别
仅ie9可识别
注:在 if 后加 lt gte有不同效果 (参加其它参数同理)
= ie8 仅ie8可识别 = ie7或更低版本 = 高于或者等于ie8版本
2、div+css实例
css实例一:
让ie6-ie8显示不同的内容,div css代码如下:
1 | <!doctype html><html><head><meta http-equiv= "content-type" content= "text/html; charset=utf-8" /><title>div if 条件实例</title></head><body>你正在使用:<!--[ if ie 7]> <h2>ie7</h2><![ endif ]--><!--[ if ie 6]> <h2>ie6</h2><![ endif ]--><!--[ if ie 8]> <h2>ie8</h2><![ endif ]--><!--[ if ie 9]> <h2>ie9</h2><![ endif ]--><br><br><strong>说明</strong>:如果你的浏览器版本为多少即会显示ie多少,针对ie6-ie9实验</body></html>
|
登入後複製
div+css实例二:说明:以上针对不同ie显示不同网页内容div+css实例实验。
让ie6-ie8显示不同css样式效果,div css代码如下:
1 | <!doctype html><html><head><meta http-equiv= "content-type" content= "text/html; charset=utf-8" /><title>css if 条件hack实例</title><!--[ if ie 6]> <style type= "text/css" >.divcss{ color:#f00;}</style><![ endif ]--><!--[ if ie 7]> <style type= "text/css" >.divcss{ color:#ff0;}</style><![ endif ]--><!--[ if ie 8]> <style type= "text/css" >.divcss{ color:#00f;}</style><![ endif ]--><!--[ if ie 9]> <style type= "text/css" >.divcss{ color:#000;}</style><![ endif ]--></head><body><div class = "divcss" >div css实验提示:<br>我在ie6下是红颜色,在ie7下是黄颜色,在ie8下是蓝颜色,在ie9下是黑色</div></body></html>
|
登入後複製
说明:以上实验仅实验ie6-ie9下if hack。