Home >Web Front-end >HTML Tutorial >Browser for web development (5) Browser compatible with CSS hack_html/css_WEB-ITnose

Browser for web development (5) Browser compatible with CSS hack_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:51:431009browse

首先,仅仅IE支持的条件注释语句

dbf5feeb0d676154b00e7fac3915442f4e255cca6c1c1c2b4c46e2b80a10fe99 除IE外都可识别 d209044b8e2138c461665ded4d2a3f8e
3b91107ae0f6dc60cbcc0243262d767f 所有的IE可识别 1b771f47d72d900ba74308aee59557f0
32bf6dd8d9e9c69afb95af0b0e5e6991 仅IE6可识别 1b771f47d72d900ba74308aee59557f0
77ff45aa02bda806843bc31600e44271 IE6以及IE6以下版本可识别 1b771f47d72d900ba74308aee59557f0
91029187a47d4c3a99cc198a5627b173 IE6以及IE6以上版本可识别 1b771f47d72d900ba74308aee59557f0
ebfe8dd00e7ea47e29f0d93ec8c68f66 仅IE7可识别 1b771f47d72d900ba74308aee59557f0
000cd64ace4601dafacd68f50829db82 IE7以及IE7以下版本可识别 1b771f47d72d900ba74308aee59557f0
f92958435b2b094c55bbcf32a6c93dd8 IE7以及IE7以上版本可识别 1b771f47d72d900ba74308aee59557f0
266c419352a525843049eb7155ebf872 仅IE8可识别 1b771f47d72d900ba74308aee59557f0
b051de22d5d282dd0df4ca82b96d4a5b 仅IE9可识别 1b771f47d72d900ba74308aee59557f0

例子

6fc79538f41ba7309e847292db36ab30

加载CSS1
59d80037ab5bf44ee6d16438840ba052
加载CSS2
1b771f47d72d900ba74308aee59557f0
这样有效是有效,但是用HTML VALIDATOR里,报错,因为这个不符合XHTML 1.1的规范,
如果把ELSE语句去掉,则正确.

方法:

加载CSS2
6fc79538f41ba7309e847292db36ab30
加载CSS1(可以把要重写的写在这里).
1b771f47d72d900ba74308aee59557f0

其次,各IE浏览器常用前缀(又是IE,我已经无力吐槽了)

*html *前缀只对IE6生效*+html *+前缀只对IE7生效@media screen\9{...}只对IE6/7生效@media \0screen {body { background: red; }}只对IE8有效@media \0screen\,screen\9{body { background: blue; }}只对IE6/7/8有效@media screen\0 {body { background: green; }} 只对IE8/9/10有效@media screen and (min-width:0\0) {body { background: gray; }} 只对IE9/10有效@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {body { background: orange; }} 只对IE10有效

再次,CSS特殊字符hack

「\9」、「*」、「_」「!important」

「\9」仅支持所有IE系列

「*」仅IE6,IE7

「_」仅IE6

「!important」仅IE7,firefox等


最后,各种特殊字符Hack实例验证

Hack应用情境(一)

适用范围:IE:6.0,IE7.0,IE8.0之间的兼容

实例代码:

.bb{
height:32px;
background-color:#f1ee18;/*所有识别*/
.background-color:#00deff\9; /*IE6、7、8识别*/
+background-color:#a200ff;/*IE6、7识别*/
_background-color:#1e0bd1;/*IE6识别*/
}

/*一个用于展示的class为bb的div标签*/

66192000bf42bc371da470065e96ccb4d7071d505605c2696124ea5fd5f10648

Hack应用情境(二)

适用范围:IE:6.0,IE7.0,IE8.0,Firefox之间的兼容

实例代码:

.bb{
height:32px;
background-color:#f1ee18;/*所有识别*/
background-color:#00deff\9; /*IE6、7、8识别*/
+background-color:#a200ff;/*IE6、7识别*/
_background-color:#1e0bd1;/*IE6识别*/
}
.bb, x:-moz-any-link, x:default{background-color:#00ff00;}/*IE7 firefox3.5及以下 识别 */ 
@-moz-document url-prefix(){.bb{background-color:#00ff00;}}/* 仅firefox 识别 */ 
* +html .bb{background-color:#a200ff;}/* 仅IE7 识别 */


/*一个用于展示的class为bb的div标签*/

66192000bf42bc371da470065e96ccb4d7071d505605c2696124ea5fd5f10648


Hack应用情境(三)

适用范围:IE:6.0,IE7.0,IE8.0,Firefox,Safari(Chrome)之间的兼容

实例代码:

.bb{
height:32px;
background-color:#f1ee18;/*所有识别*/
background-color:#00deff\9; /*IE6、7、8识别*/
+background-color:#a200ff;/*IE6、7识别*/
_background-color:#1e0bd1;/*IE6识别*/
}
@media screen and (-webkit-min-device-pixel-ratio:0){.bb{background-color:#f1ee18}}{} /*safari(Chrome) 有效 */
.bb, x:-moz-any-link, x:default{background-color:#00ff00;}/*IE7 firefox3.5及以下 识别 */ 
@-moz-document url-prefix(){.bb{background-color:#00ff00;}}/*仅firefox 识别*/ 
* +html .bb{background-color:#a200ff;}/* 仅IE7 识别 */


/*一个用于展示的class为bb的div标签*/

66192000bf42bc371da470065e96ccb4d7071d505605c2696124ea5fd5f10648

Hack应用情境(四)(GOOD)

适用范围:IE:6.0+,FireFox:2.0+,Opera 10.0+,Sarari 3.0+,Chrome全兼容

实例代码:

189f857547afbf737a6cbb41178b2b34

780896dc32bfe6b4ba74143715487715

93f0f5c25f18dab9d176bd4f6de5d30e

fd6068792e6abaaade6427adaeb52952

46d5fe1c7617e3914f214aaf043f4ccf

/***************************************** All browsers are compatible with CSS ****** ****************************************/
.bb{height:32px;background-color:#f1ee18;/*All recognitions*/ background-color:#00deff9; /*IE6, 7, 8 recognition* / background-color:#a200ff;/*IE6, 7 recognition*/ _background-color:#1e0bd1/*IE6 recognition*/}

@media screen and (-webkit-min-device-pixel-ratio :0){.bb{background-color:#f1ee18}}{} /* Safari(Chrome) valid*/
@media all and (min-width: 0px){ .bb{background-color:#f1ee18 ;/*opera and Safari(Chrome) and firefox*/ background-color:#4cac70

ebfe8dd00e7ea47e29f0d93ec8c68f66The distinguishing color of IE7 is purple, IE7 can still be used! 1b771f47d72d900ba74308aee59557f0

32bf6dd8d9e9c69afb95af0b0e5e6991The identification color of IE6 is red, but IE6 is a bit behind! 1b771f47d72d900ba74308aee59557f0

16b28748ea4df4d9c2150843fecfba68

36cc49f0c466276486e50c850b7e4956

73a6ac4ed44ffec12cee46588e518a5e

Attach. Table:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn