CSS compatibility issues in IE6/IE7/IE8/Firefox

Source: Internet
Author: User

1. Use of the symbol.

Both IE6 and IE7 can recognize *, but neither IE8 nor Firefox can recognize it. See the following style

# Wintop
{
Background: url(body-top.gif) top repeat-X;
Margin-top: 10px;
* Margin-top: 0px;
}

In IE6 and IE7, it is interpreted as 0 pixels away from the top margin because it can recognize *, so * margin-top: 0px overwrites the above 10px. In IE8 and Firefox, because it cannot recognize *, it is still interpreted as 10 pixels away from the top margin.

2. * HTML for IE6

. Content
{
Background-color: Gray;
Width: 200px;
Height: 200px;
Left: 0px;
Top: 0px;
}
* Html. Content
{
/* IE6 */
Margin-top: 100px;
}

The 100 pixels of margin-top only work for IE6.

3 .! Important does not recognize IE6, so we can also use it to handle the difference between IE6 and IE7/IE8/ff.

. Content
{
Background-color: Gray;
Width: 200px;
Height: 200px;
Left: 0px;
Top: 0px;
Margin-left: 0px! Important;
Margin-left: 100px;
}

Note: In IE7, IE8, and Firefox, it is preferred to include! Important element, so the following margin-left: 100px won't overwrite the above margin-left: 0px! Important.

For IE6, however, it can only recognize margin-left: 100px.

4. * And! The following example shows how to use important in combination:

Background-color: # ff0000! Important;
* Background-color: #00ff00! Important;
* Background-color: # 0000ff;
Background-color: #000000;

In ff and IE8, the first line takes effect.

In IE7, the second line works.

In IE6, row 4 takes effect.

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.