Various browser CSS hack

Source: Internet
Author: User

When you write CSS, the style sheet plus the browser identifier is OK, the browser differences are as follows:

IE can recognize *, the standard browser (such as FF) is not recognized *;
IE6 can identify the *, but does not recognize!important;
IE7 can recognize *, can also identify!important;
IE8 can recognize the *,+,_,* and not recognize the!important;
FF does not recognize *, but can identify!important;
For example style= "*width:10px!important; width:20px; "
This way, the width is 10px under IE6, and the width of IE7 is 20px

There are also three ways of writing:

1 Kinds:
width:100px; /* Firefox and other browsers */
width:200px\0; /* IE8 can identify \0*/
*width:300px!important; /*, IE7 can recognize both * and important */
*width:400px; /* IE6 can also identify * * *
/* Note ORDER */

2 Kinds:
width:100px; /* Firefox and other browsers */
width:200px\0; /* IE8 can identify \0*/
*width:300px; /* IE7 can also identify * * *
_width:400px; /* IE6 can recognize the underline */
/* Note ORDER */

3 Kinds:
width:100px; /* Firefox and other browsers */
width:200px\0; /* IE8 can identify \0*/
+width:300px; /* + only recognize IE7 */
_width:400px; /* IE6 can recognize the underline */
/* Note ORDER */

1..color1{color: #F00; color/*\**/: #00F/*\**/}/*ie6,ie7,ie8,ff,op,sa Recognition */
2..color2{color: #F00; color/*\**/: #00F/*\9**/}/*ie7,ie8,ff,op,sa Recognition */
3..color3{color: #F00; color/*\**/: #00F \9}/*ie6,ie7,ie8 Recognition */
4..color4{color: #F00; color/*\**/: #00F \9}/*ie7,ie8 Identify a space between *//* "color" and "/*\**/" */
Where: Op means Opera,sa represents safari
————————————-
Hack supported independently by various browsers:
width:100px\0;/* Support IE8 */

_width:100px; /* Support IE6 */

[width:100px;/* Support ie6,7 */

+width:100px; /* Support ie6,7 */

*width:100px; /* Support ie6,7 */

*width:100px!important; /* Support ie6,7, */

*+width:100px; /* Support ie6,7, */

*+width:100px!important;/* supports ie6,7, */

width:100px\9; /* Support ie6,7,8 */

Width:100px!important; /* Support IE6,7,8,FF */

w\idth:100px; /*ie5.x does not support IE6, IE7, IE8, FF support */

------------------
IE Conditional comment function:

<!--[if ie]> this content is only IE visible <! [endif]–>
<!–[if IE 6.0]> This content is only IE6.0 visible <! [endif]–>
<!–[if IE 7.0]> This content is only IE7.0 visible <! [endif]–>

Various browser CSS hack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.