Instance code: Method of using @media to implement IE hack

Source: Internet
Author: User
Tags end implement min version

Article Introduction: as we all know, sometimes in order to achieve some of the effects of IE in line with modern browsers, we have to use some hack means to achieve the goal. For example, the use of "", "\" and "\9" to allow only some version of IE to identify, and for modern browsers, he will directly ignore the code. Today I want to introduce you to the use of @media to achieve IE hack method.

With the popularity of responsive design, medial queries can be regarded as more and more people to watch. He can let the Web front-end project to achieve different devices under the choice of style, so that the site in different devices to achieve different results. This earlier in W3cplus already introduced, if you have not contacted, do not imitate click here to read in detail. Today in the blog to find a other way to use, is to use @media to do some of the special effects of IE.

As we all know, sometimes in order to achieve some of the effects of IE in line with modern browsers, we have to use some hack means to achieve the goal. For example, the use of "", "\" and "\9" to allow only some version of IE to identify, and for modern browsers, he will directly ignore the code. Today I want to introduce you to the use of @media to achieve IE hack method:

Only IE6 and IE7 recognition

@media screen\9 {   . selector {  Property:value}}}  

Only IE6 and IE7, IE8 recognition

@media \0screen\,screen\9 {   . selector {  

Only IE8 recognition

@media \0screen {   . selector {  

Only ie8-10 recognition

@media screen\0 {   . selector {  Property:value}}}  

Only IE9 and IE10 recognition

@media screen and (min-width:0\0) {   . selector {  Property:value}}}  

Only IE10 recognition

@media screen and (-ms-high-contrast:active), (-ms-high-contrast:none) {    

The above several @media with "\", "the" and "\9" can let different version of IE recognition, then the specific project how do we use it?

For example, if you have a red background in your body, and you want different versions of IE to turn into another color, then we can do that.

body {   background:red;}  /* IE6, IE7 into green/@media all\9 {body   {     background:green;   }}  /* IE8 to Blue/@media \0screen {body   {     background:blue   }}/*ie9 and IE10 into yellow/@media screen and Min-width: 0\0) {body   {      background:yellow    }}}    

ie hack method I always do not advocate the use, but these methods few people know, posted up to share with you, hope that in the last resort, these hack methods can help you solve problems, especially the domestic bitter force front-end personnel.



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.