9和css中\ \ 0为什么可能破解IE11 \ IE9 \ IE8无效

  介绍

这篇文章给大家分享的是有关9和css中\ \ 0为什么可能破解IE11 \ IE9 \ IE8无效的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

每次设计一张网页或一个表单,都被各种浏览器的兼容问题伤透脑筋,尤其是IE家族。在做兼容性设计时,我们往往会使用各种浏览器能识别的独特语法进行攻击,从而达到各种浏览器下显示正常的目的。其中,我们用得最多莫属于9和\ \ 9和0了。\ \ 0是黑客IE8, IE9, IE11的独特标识。但是问题来了,9和\ \ 0到底怎样黑客IE8, IE9, IE11这三个浏览器?这个问题一直困扰我很久,不过,今天我终于搞明白了,也独创了一个能破解IE8, IE9, IE11这三个浏览器的代码写法模式,本文将与各位分享。

<强> \ 9和\ 0为什么可能破解IE11 \ IE9 \ IE8无效?

可能很多人都略明白,\ 0是用来破解IE8, IE9, IE11的,而\ 9是用来破解IE9的。但有时你真正运用起来,它并不凑效。看下面的html代码:

& lt; ! DOCTYPE  html>   & lt; head>   ,,,& lt; meta  http-equiv=癈ontent-Type",内容=皌ext/html;, charset=utf-8"/比;   ,,,& lt; title> hack  IE8/IE9 IE11_css实例_卡卡网,webkaka.com   ,,,& lt; style 类型=拔谋?css"比;   ,,,.content {   ,,,,,,,,,宽度:400 px;高度:50 px;颜色:# ccc;   ,,,,,,,,,background - color: # FF0000;,,/*,红色,*/,   ,,,,,,,,,background - color: # 0000 ff \ 0;,,/*,蓝色,*/,,,,,,,,,background - color: # FFFF00 \ 9;,,/*,黄色,*/,,,}   ,,,& lt;/style>   & lt;/head>   & lt; body>   ,,,,& lt; div 类=癱ontent"祝辞IE8  IE9  IE11均显示黄色& lt;/div>   & lt;/body>   & lt;/html>

测试地址:http://demo.jb51.net/html/ie-hack/ie-hack1.html

上例中,9和\ \ 0就达不到黑客各IE浏览器版本的目的。不过我们把/*蓝色*/和/*黄色*/这两行调换,又会怎样显示呢?请看html代码:

& lt; ! DOCTYPE  html>   & lt; head>   ,,,& lt; meta  http-equiv=癈ontent-Type",内容=皌ext/html;, charset=utf-8"/比;   ,,,& lt; title> hack  IE8/IE9 IE11_css实例_卡卡网,webkaka.com   ,,,& lt; style 类型=拔谋?css"比;   ,,,.content {   ,,,,,,,,,宽度:400 px;高度:50 px;颜色:# ccc;   ,,,,,,,,,background - color: # FF0000;,,/*,红色,*/,   ,,,,,,,,,background - color: # FFFF00 \ 9;,,/*,黄色,*/,,,,,,,,,background - color: # 0000 ff \ 0;,,/*,蓝色,*/,,,}   ,,,& lt;/style>   & lt;/head>   & lt; body>   ,,,,& lt; div 类=癱ontent"祝辞IE11显示黄色,IE8  IE9 均显示蓝色& lt;/div>   & lt;/body>   & lt;/html>

测试地址:http://demo.jb51.net/html/ie-hack/ie-hack2.html

结果是,IE11显示黄色,而IE8和IE9均显示蓝色。

上述两个例子说明,IE8, IE9都能读懂\ 9和\ 0标识,此两标识哪个写在后面就以哪个为准,而IE11仅能读懂\ 9标识。

至此,我们能否根据上述结论来写代码来破解IE8, IE9和IE11三个浏览器?显然是不可以的,至少你不可以hackIE8和IE9,仅能hackIE11。

如何破解IE8和IE9
那么,我们如何去破解IE8和IE9呢?这个就是问题的关键。

在此文css区分IE8/IE9/ie10浏览器/IE11 chrome浏览器firefox的代码中提到,IE9以上浏览器可以读懂此代码:

/*, IE9 + */@media  all 以及(min-width: 0), {   ,,,.divContent {   ,,,,,,,background - color: # eee;   ,,,}   }

我们用此代码结合前面的代码,是不是就可以黑客IE8和IE11了?完整的html代码如下:

& lt; ! DOCTYPE  html>   & lt; head>   ,,,& lt; meta  http-equiv=癈ontent-Type",内容=皌ext/html;, charset=utf-8"/比;   ,,,& lt; title> hack  IE8/IE9 IE11_css实例_卡卡网,webkaka.com   ,,,& lt; style 类型=拔谋?css"比;   ,,,.content {   ,,,,,,,,,宽度:400 px;高度:50 px;颜色:# ccc;   ,,,,,,,,,background - color: # FF0000;,,/*,红色,*/,   ,,,,,,,,,background - color: # FFFF00 \ 9;,,/*,黄色,*/,,,,,,,,,background - color: # 0000 ff \ 0;,,/*,蓝色,*/,,,}   ,,,/*,IE9 + */,,,@media  all 以及(min-width: 0), {   ,,,,,,,.content {   ,,,,,,,,,,,background - color: # 000;,,,/*,黑色,*/,,,,,,,}   ,,,}   ,,,& lt;/style>   & lt;/head>   & lt; body>   ,,,,& lt; div 类=癱ontent"祝辞IE11显示黄色,IE8 显示蓝色,IE9显示黑色。;/div>   & lt;/body>   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

9和css中\ \ 0为什么可能破解IE11 \ IE9 \ IE8无效