一、通用区分方式:

IE6、IE7能识别*,标准浏览器(如FF)不能识别*;
IE6能识别*,但不能识别 !important;
IE7能识别*,也能识别 !important;
IE8能识别\0,不能识别*,+,_,* 加!important;
FF不能识别*,但能识别 !important;
例如style=”*width:10px!important; width:20px;”,其在IE7下宽度为10px,在IE6下宽度是20px.

其中还有如下三种写法:

第一种

width:100px; /* FireFox及其他浏览器 */
width:200px\0; /* IE8能识别\0*/
*width:300px!important; /* ,IE7 既能能识别*号,也能识别important */
*width:400px; /* IE6也能识别*号 */
/*提示:请注意书写顺序*/
 

第二种

width:100px; /* FireFox及其他浏览器 */
width:200px\0; /* IE8能识别\0*/
*width:300px; /* IE7也能识别*号 */
_width:400px; /* IE6能识别下划线*/
/*提示:请注意书写顺序*/
 

第三种

width:100px; /* FireFox及其他浏览器 */
width:200px\0; /* IE8能识别\0*/
+width:300px; /* +只识别IE7 */
_width:400px; /* IE6能识别下划线*/
/*提示:请注意书写顺序*/
 

二、不常见的HACK(OP表示Opera,SA表示Safari),其中第3条比较实用

1..color1{ color:#F00; color/*\**/:#00F /*\**/}/*IE6,IE7,IE8,FF,OP,SA识别*/
2..color2{ color:#F00; color /*\**/:#00F /*\9**/}/*IE7,IE8,FF,OP,SA识别*/
3..color3{ color:#F00; color/*\**/:#00F \9}/*IE6,IE7,IE8识别*/
4..color4{ color:#F00; color /*\**/:#00F\9}/*IE7,IE8识别*//*“color”和“/*\**/”之间有个空格*/

三、各种浏览器独立支持的hack

width:100px\0;/* 支持IE8 */
_width:100px; /* 支持IE6 */
[width:100px; /* 支持IE6,7 */
+width:100px; /* 支持IE6,7 */
*width:100px; /* 支持IE6,7 */
*width:100px!important; /* 支持IE6,7, */
*+width:100px; /* 支持IE6,7, */
*+width:100px!important;/* 支持IE6,7, */
width:100px\9; /* 支持IE6,7,8 */
width:100px!important; /* 支持IE6,7,8,FF */
w\idth:100px; /*IE5.x不支持 IE6、IE7、IE8、FF支持 */

四、IE特有的html条件注释使用规则

 Example Source Code
<!--[if IE 7]> 
<style type="text/css"> 
</style>
<![endif]-->
 <!--[if IE 6]> 
<style type="text/css">
</style> 
<![endif]-->

1.仅IE可见的写法

<!--[if IE]>此处内容只有IE可见<![endif]-->
 

2.仅IE6可见的写法

<!--[if IE 6]>此处内容只有IE6.0可见<![endif]-->
 

3.仅IE7可见的写法

<!--[if IE 7]>此处内容只有IE7.0可见<![endif]-->
 

4.版本区间可显示写法

<!--[if lt IE 6]>IE6以及IE6以下版本可识别<![endif]-->
<!--[if gte IE 6]>IE6以及IE6以上版本可识别<![endif]-->
<!--[if lt IE 7]>IE7以及IE7以下版本可识别<![endif]-->
<!--[if gte IE 7]>IE7以及IE7以上版本可识别<![endif]-->
PS:区间注释代码实际用起来貌似不包括本区间,这里需要注意下
 

5.非IE可见的写法(注意:此条不符合WEB标准,但的确实用)

<!--[if !IE]>此处内容只非IE可见<![endif]-->
 

PS1:IE8降级为IE7:<meta http-equiv="X-UA-Compatible" content="IE=7">

PS2:解决chrome不支持12号以下字体的代码:-webkit-text-size-adjust:none;

PS3:li左侧ico样式:li { list-style:disc outside none; }

 
EX SP:
.box   
{   
    color: black;                              /* ff */  
    color: #fff\9\0;                            /* IE9 */  
    color: #ff0000\0;                       /* IE8 */  
    [color: #666; color: #999;       /* Safari Chrome */  
    *color: green;                           /* IE7 */  
    _color: blue;                             /* IE6 */  
}  
@media all and (min-width: 0px){
/* Safari与Opera浏览器的共同样式 */
 }
@media all and (-webkit-min-device-pixel-ratio:0){
 /* 这里单独设置Safari的样式 */
}
 HTML代码
<div class="box">  
这里根据设置不同浏览器的CSS HACK显示不同的颜色!   
</div>  
在IE6浏览器中字体颜色为蓝色;
在IE7浏览器中字体颜色为绿色;
在IE8浏览器中字体颜色为红色;
在IE9浏览器中字体颜色为白色;
在Firefox浏览器中字体颜色为黑色;
在safari、Chrome浏览器中字体颜色为灰色。

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
第一个 强制使用机器上最新版的IE
第二个 360默认的浏览器内核会优先使用极速内核

针对主流浏览器的CSS-HACK写法及IE常用条件注释的更多相关文章

  1. 兼容不同浏览器的 CSS Hack 写法

    所谓 CSS Hack,是指在 CSS 代码中嵌入诸如 *,*html  等代码,方便于独立控制某种浏览器的具体样式.比如有些 CSS Hack 只能被 IE6 或 IE7 识别,而 Firefox ...

  2. CSS- ie6,ie7,ie8 兼容性写法,CSS hack写法

    css ie6,ie7,ie8 兼容性写法,CSS hack写法 margin-bottom:40px;       /*ff的属性*/margin-bottom:140px\9;    /* IE6 ...

  3. 针对不同浏览器,CSS如何写

    我们在开发DIV+CSS页面时候常常会遇到开发出的网页的一些地方在各大浏览器比如微软IE6.微软IE7.微软IE8.火狐浏览器.谷歌浏览器有一些不同,如宽度.高度等地方有相差误.IE6比较老的版本浏览 ...

  4. android 4.4.3 css hack 写法

    最近发现android在4.4.3上面出现很多怪异的现象,现在虽然没有找到原因和解决方案,但是突然间找到一个css hack写法: button{ display:none; width:$rem*4 ...

  5. 针对IE浏览器的CSS样式(兼容性)

    1. IE hacks: "_"  是IE6 专有的hack; "\9" 对IE6-IE10都有效: "\0"对IE8-IE10都有效: & ...

  6. IE9下css hack写法

    ie9一出css hack也该更新,以前一直没关注,今天在内部参考群mxclion分享了IE9的css hack,拿出来也分享一下: select { background-color:red\0; ...

  7. IE 6 ~ 9 CSS Hack 写法总结

    IE 6 ~ 9 CSS Hack 写法总结 24th 四, 14 lip2up [code lang="css"]_color: red;    /* ie6 */*color: ...

  8. 兼容主流浏览器的CSS透明代码

    透明往往能产生不错的网页视觉效果下面是兼容主流浏览器的CSS透明代码.transparent_class {  filter:alpha(opacity=50);  -moz-opacity:0.5; ...

  9. (转)兼容主流浏览器的CSS透明代码

    透明往往能产生不错的网页视觉效果下面是兼容主流浏览器的CSS透明代码.transparent_class { filter:alpha(opacity=50); -moz-opacity:0.5; - ...

随机推荐

  1. PHP及Javascript 正则判断中文(转)

    UTF-8匹配: 在javascript中,要判断字符串是中文是很简单的.比如: var str = "php编程"; if (/^[\u4e00-\u9fa5]+$/.test( ...

  2. 微软.NET Framework 4.5.2 RTM正式版

    今天,微软.NET开发团队发布.NET Framework 4.5.2 RTM正式版.新版框架继续高度兼容现有的.NET Framework 4.4.5.4.5.1等版本,该版本框架与旧版的.NET ...

  3. iphone获取当前运行进程列表

    通过调用 sys/sysctl.h 读取系统内核获取进程列表 . 代码悦德财富:https://yuedecaifu.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 ...

  4. linux命令存放 bash: xxx command not found

    参考资料:http://blog.sina.com.cn/s/blog_688077cf01013qrk.html 提示:bash: xxx command not found 首先就要考虑root ...

  5. Android常见控件— — —TextView

    <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=&qu ...

  6. 团队博客——Sprint计划会议1

    每日Scrum:第一天 会议时间:4.14.晚八点半 会议地点:基础教学楼一楼大厅 小组成员:郭庆樑,林彦汝,张金 认领人—使团队成员分工合作,保持团队的积极性. ID 名称(NAME) 重要性(IM ...

  7. Arrays.equals()

    我们知道判断字符串相等使用的是equals方法,那么要是判断两个字符串数组是否相等呢,要是char数组呢,同样的java.util.Arrays类提供了equals()方法,如下是官方API: /** ...

  8. 使用Office 365 试用账户 体验Office 365功能

    首先,需要申请Office 365 Enterprise E3版本的试用账户. 在浏览器中,输入以下地址,然后回车: http://products.office.com/en-us/business ...

  9. Magento中,调用静态块的几种方法

    在后台创建一个order_form静态块Block Title :Order FormIdentifier :order_formStatus :EnabledContent :自定义内容 1.如果要 ...

  10. LeetCode Implement Stack using Queues (数据结构)

    题意: 用队列来实现栈. 思路: 没有什么捷径,纯粹模拟.但是用一个队列就够了. class Stack { /* // Push element x onto stack. void push(in ...