The hack method of important in ie7.0

Source: Internet
Author: User
Tags filter empty linux
Because IE to!important recognition of bugs, and now most of the Web standard designers through this bug to compatible with IE and FF, but ie7.0 to fix the bug, so the problem arises, how compatible with the ie.7.0 while compatible with ie6.0 and FF?

Is the so-called "on the policy, there are countermeasures", foreign Web page standard designers through the use of CSS filter (not CSS hack) to compatible with ie7.0,ie6.0 and FF, the following x2hu from the foreign website translation.

Create a new CSS style as follows

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


Create a new div and use the CSS style defined earlier

Program code &LT;DIV id= "Item" >some text here</div>

In the body manifestation here join lang attribute, Chinese as en

Program code <body lang= "EN" >

Now define a style for the DIV element

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

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


Program code #item:empty {
Background:green!important
}

The empty selector is a CSS3 specification, and although Safari does not support this specification, it still chooses this element, regardless of whether or not this element exists, now Green will now be on browsers other than IE versions, and tested 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

In fact, according to far-away authors, this is not a kind of hack, should belong to filter, but this does not seem to be the most important, because this way, we once again solve ie6.0,ie7.0 and other browser compatibility issues, and use: Lang-filter this approach, will be useful for some time to come.

Original address: http://www.ibloomstudios.com/article7/

Thanks to the translator!


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.