The hack method of!important in ie7.0 _css/html

Source: Internet
Author: User
Because the IE to!important recognition exists bug, and now most of the Web page standard designer through this bug to compatible with IE and FF, but ie7.0 this bug to fix, so the problem arises again, how compatible with ie.7.0 and can be compatible with ie6.0 and FF? There are policies, there are countermeasures ", foreign web standards designers by using CSS Filter method (not CSS hack) to compatible with ie7.0,ie6.0 and FF, the following is my translation from foreign sites.

Create a new CSS style as follows:

#item {
width:200px;
height:200px;
background:red;
}

Create a new div and use the style of the CSS that you defined earlier:

Some text here

Add the lang attribute to the body expression, in Chinese en:



Now define a style for the DIV element:

*:lang (en) #item {
Background:green!important;
}

This is done in order to overwrite the original CSS style with!important, because: lang selector ie7.0 does not support, so this sentence will not have any effect, so also achieved the same effect ie6.0, but unfortunately, Safari also does not support this property, So you need to add the following CSS styles:

#item: Empty {
Background:green!important
}


: The empty selector is a CSS3 specification, and although Safari does not support this specification, it will still be selected, whether or not this element exists, and now Green will now be tested in browsers other than IE versions and under the following browsers and operating systems:

IE7 Beta 2 Preview/win
Ie5.01+/win
Firefox 1.5/win
Opera 8.5/win & Linux
Netscape 7.01, 8/win
Mozilla 1.7.12/win & Linux
Safari 2/mac
Firefox 1.0.4/linux
Epiphany 1.4.8/linux
Galeon 1.3.20/linux


According to the far author's argument, this is not a hack, it should belong to the filter, but this does not seem to be the most important, because through this approach, we have once again resolved the compatibility between ie6.0,ie7.0 and other browsers, and use: Lang-filter this approach, will be useful for some time to come.
  • 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.