CSS IE6/7/8, Firefox, Safari, chrome, and opera hack

Source: Internet
Author: User
Document directory
  • CSS hack1: differentiate IE6/7/8 from other browsers
  • CSS hack2: For IE6 and IE7
  • CSS hack3: For IE6
  • CSS hack4: For IE7
  • CSS hack5: For IE8
  • CSS hack6: For Firefox
  • CSS hack7: for opera
  • CSS hack8: For Safari and Google Chrome

There are many articles about IE6/7/8, Firefox, Safari, chrome, and opera CSS hack on the Internet. However, I think it is too complicated to give a CSS hack induction table that I cannot understand, otherwise, a lot of code is provided to illustrate the problem, which is not easy to learn and use. I have summarized the CSS hack usage methods of IE6/7/8, Firefox, Safari, chrome, and Opera based on my usage. I hope it will be useful to you.

CSS hack1: differentiate IE6/7/8 from other browsers

Add "\ 9" (not including double quotation marks) after the CSS code attribute value, for example:

123 #div {margin-top:
15px\9;}

* In this way, the "margin-top: 15px" attribute can only be read by IE6/7/8 browsers.

CSS hack2: For IE6 and IE7

Add "*" (not including double quotation marks) before the attribute name of the CSS code, for example:

123 #div {*margin-left:
15px;}

* In this way, the "margin-left: 15px" attribute can only be read by IE6/7.

CSS hack3: For IE6

Add "_" (not including double quotation marks) before the attribute name of the CSS code, for example:

123 #div {_width:
15px;}

* In this way, the "width: 15px" attribute can only be read by the IE 6 browser.

CSS hack4: For IE7

Add "! Important "(not including double quotation marks), for example:

123 #div {height:
18px !important;}

* In this way, the "height: 18px" attribute can only be read by the IE 7 browser.

CSS hack5: For IE8

Add "\ 0" after the attribute value of the CSS code (it is a slash plus zero, not including double quotation marks), such:

123 #div {background:
green\0;}

* In this way, the "Background: Green" attribute can only be read by the IE 8 browser.

CSS hack6: For Firefox

Write the CSS code for Firefox between the braces of the following CSS Function
@-Moz-document URL-prefix () {/* CSS Code */}, for example:

123 @-moz-document url-prefix(){#main {background:
red; }}

* In this way, the HTML element with the ID number "Main" will only display the "Background: Red" effect in Firefox.

CSS hack7: for opera

Write the CSS code for opera in the braces of the following CSS function.
@ Media all and (-WebKit-Min-device-pixel-ratio: 10000), not all and (-WebKit-Min-device-pixel-ratio: 0) {/* CSS Code */}, such:

123 @media all
and (-webkit-min-device-pixel-ratio:10000), not
all and (-webkit-min-device-pixel-ratio:0){#content {background:
url(http://guandian.co/logo.jpg)
no-repeat center
top;} }

* In this way, the HTML element with the ID "content" only displays the effect of "Background: URL (http://guandian.co/logo.jpg) No-repeat center top" in opera.

CSS hack8: For Safari and Google Chrome

Write the CSS code for Safari and Google Chrome between the braces of the following CSS function.
@ Media screen and (-WebKit-Min-device-pixel-ratio: 0) {/* CSS Code */}, for example:

123 @media screen
and (-webkit-min-device-pixel-ratio:0){#picture {background:
url(http://guandian.co/mypic.gif)
no-repeat center
top;}}

* In this way, the HTML element with the ID "picture" only displays the effect of "Background: URL (http://guandian.co/mypic.gif) No-repeat center top" in Safari and Google Chrome. However, if the safari and Google Chrome kernel versions are different, the CSS display effect may also be different.

The above is my own CSS hack. However, due to my limited technical skills, there are still many incomplete or unreasonable aspects. Please come up with me. Thank you.

Http://guandian.co/program/css-hack-ie678-firefox-safari-chrome-opera/

Related Article

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.