About css compatibility issues and practices

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

Identify the difference

Difference IE6, IE7, IE8, FF.

  1. * IE can identify; standard browser (e.g., FF) * can not be recognized;

  2. * IE6 can recognize, but can not identify Important;! _ IE6 style prepended

  3. * IE7 can identify, but also to identify important!;

  4. IE8 recognizes \ 9 example: background: red \ 9;

  5. * firefox does not recognize, but can identify important!;

(1) IE6 and firefox difference:

/* 火狐浏览器的背景颜色是橙色,而IE浏览器的背景色是蓝色 */
background:orange;*background:blue;

(2) IE6 and IE7 difference:

/* IE7的背景颜色是绿色,IE6的背景颜色是蓝色 */
background:green !important;background:blue;

(3) IE7 and FF differences:

/* 火狐浏览器的背景颜色是橙色,而IE7的背景颜色是绿色 */
background:orange; *background:green;

(4) FF, IE7, IE6 distinction:

/* 火狐浏览器的的背景橙色,IE7浏览器的背景颜色是绿色,而IE6浏览器的颜色是蓝色. */
background:orange;
*background:green !important;
*background:blue;

Practices

Select (1) development platform
to write css in Firefox (Firefox), also compatible with other browsers.
To do so would surely be in IE and then do another browser compatibility is easier, because IE support for the old standard is still very good, and some of the unique features of IE do not support people. It is recommended in conjunction with the Firebug extension to Firefox as a platform .

Order (2) CSS Hack is
using Firefox as a platform, as long as the code is written standard enough, in fact, to Hack a place not many.
Browsers other than IE almost will not matter, so you can ignore.

In the following order: Firefox -> IE6 -> IE7 -> Other

(3) Hack method
comes in two ways:
one is treated in a different file, the other is processed in the same file.
In fact, the role is the same, but just not the same way.

The same file handle is an attribute to find ways compatible browser you want compatible.

Why the same file can be processed but also to write in multiple files inside for different browsers? This is to deceive the W3C validation tool, in fact, only two files, one for all browsers, a service only for IE. All code written to comply with a W3C inside, while necessary in IE, but not verified by W3C codes (eg: cursor: hand;) into another file, and then introducing the following method.

<!--[if IE]>
	<link href="兼容IE的css样式.css" rel="stylesheet">
<![endif]-->

This code only IE can be identified, that is only introduced in the IE browser, which is dealing in different files.
In fact, as long as the code is robust enough norms and, furthermore increasingly popular with web reason, there are only two browsers: the browser and IE.
I think, after the browser compatibility is no longer a headache.
If you do not understand this code, please visit this article to learn.

Guess you like

Origin blog.csdn.net/weixin_44198965/article/details/94339250