CSS compatibility between ie6.0, ie7.0 and Firefox

Source: Internet
Author: User

I use most of them now! Important comes to hack. It can be displayed normally for IE6 and Firefox tests, but IE7 is correct! Important

The correct explanation will cause the page not to be displayed as required! After searching, find a good hack Method for IE7 and use"

* + Html ". Now you can use IE7 to browse it. It should be okay.

  

You can write a CSS file as follows:

  

# Example {color: #333;}/* Moz */

* Html # example {color: #666;}/* IE6 */

* + Html # example {color: #999;}/* IE7 */

  

The font color in Firefox is displayed as #333, the font color in IE6 is displayed as #666, And the font color in IE7 is displayed as #999,

They do not interfere with each other.

  

-------------

  

1. doctype affects CSS Processing

2. FF: When Div sets margin-left and margin-Right to auto, it is already centered, and IE does not work.

3. FF: when setting text-align for the body, set margin: auto (mainly margin-left, margin-

Right) can be centered

4. FF: After padding is set, the DIV will increase the height and width, but IE will not, so you need to use it! Important many

Set a height and width

5. FF: supported! Important, ie is ignored, available! Important sets a special style for ff. It is worth noting that,

Make sure to change XXXX! The important sentence is placed on the other sentence.

6. Vertical center problem of Div: vertical-align: middle; Increase the line spacing to the same height as the entire Div line-

Height: 200px; insert the text to center vertically. The disadvantage is that you need to control the content rather than line feed.

7. cursor: pointer can display the cursor finger in IE ff at the same time. Hand can only be IE

8. FF: adds a border and a background color to the link. You must set display: block and float: left to avoid line breaks. Parameter

Based on the menubar, set the height for a and menubar to avoid misplacement of the bottom side. If the height is not set, you can

Insert a space.

9. The box model interpretation in Mozilla Firefox and IE is inconsistent, resulting in a 2px difference. Solution: div {margin: 30px!

Important; margin: 28px ;}

Note that the order of the two margin entries must not be reversed. According to Alibaba Cloud! The important attribute ie cannot be recognized,

The browser can recognize it. So in IE, it is actually explained as follows: div {maring: 30px; margin: 28px}

If the definition is repeated, execute the last statement. Therefore, you cannot write only margin: xxpx! Important;

  

10. The box interpretations of ie5 and IE6 are inconsistent.

Div {width: 300px; margin: 0 10px 0 10px;} under ie5 ;}

The DIV width is interpreted as 300px-10px (right fill)-10px (left fill). The final Div width is 280px, while in IE6 and other

The browser width is calculated based on PX + 10px (right filling) + 10px (left filling) = 320px. In this case, we can make the following changes:

Div {width: 300px! Important; width/**/: 340px; margin: 0 10px 0 10px}

I don't quite understand what/**/is. I only know that both ie5 and Firefox support this, but IE6 does not. If someone understands this

Please let me know. Thank you! :)

  

11. UL labels have padding values by default in Mozilla, while in IE, only margin has values, so ul is defined first.

{Margin: 0; padding: 0 ;}

Most problems can be solved.

  

Note:

  

1. The DIV of float must be closed.

  

For example: (floata and floatb attributes have been set to float: Left;) <# Div id = // "floata/">

<# Div id = // "floatb //">

<# Div id = // "notfloatc //">

The notfloatc here does not want to continue translation, but wants to move down.

This code has no problem in IE, and the problem lies in ff. The reason is that notfloatc is not a float label and must be closed.

.

In the <# Div class = // "floatb //">

<# Div class = // "notfloatc //">

<# Div class = // "Clear //">

This Div must pay attention to the declaration position, must be placed in the most appropriate place, and must be the same as the two DIV with the float attribute

Level. No nested relationship exists between them; otherwise, an exception occurs.

And define the clear style as follows:. Clear {

Clear: Both ;}

In addition, in order to automatically adapt to the height, overflow: hidden should be added to the wrapper;

When a box containing float is automatically adapted to the IE environment, it is invalid. In this case, the private attribute layout of IE should be triggered (

IE !) Zoom: 1; can be used to achieve compatibility.

For example, a wrapper is defined as follows:. colwrapper {

Overflow: hidden;

Zoom: 1;

Margin: 5px auto ;}

  

2. The problem of doubling margin.

  

The DIV set to float doubles the margin set in IE. This is a bug in IE6.

The solution is to add the display: inline In the div;

For example:

<# Div id = // "imfloat //">

  

The corresponding CSS is

# Iamfloat {

Float: left;

Margin: 5px;/* 10 Px in IE */

Display: inline;/* in IE, It is understood as 5px */}

  

3. Container inclusion relationships

  

In many cases, especially when the container has a parallel layout, such as two or three float Divs, the width is prone to problems. In IE

The width of the outer layer is broken by the DIV with a wider inner layer. You must use Photoshop or firework to obtain pixel-level precision.

  

4. Questions about height

  

If the content is added dynamically, it is best not to define the height. The browser can automatically scale. However, if the content is static

Degree is best set. (It seems that sometimes it will not be automatically pushed down and I don't know what's going on)

  

5. the most cruel means -! Important;

  

If there is no way to solve some detailed problems, you can use this method. FF "! Important will automatically give priority to resolution, however

IE will ignore. as follows. tabd1 {

Background: URL (/RES/images/up/tab1.gif) No-repeat 0px 0px! Important;/* style

FF */

Background: URL (/RES/images/up/tab1.gif) No-repeat 1px 0px;/* style for IE */}

It is worth noting that XXXX must be added! Important is placed on the other sentence, which has been mentioned above

  

When ie7.0 came out, there were new problems with CSS support. When there are more browsers, the webpage compatibility is worse.

To solve ie7.0 compatibility problems, I found the following article:

  

I use most of them now! Important comes to hack. It can be displayed normally for IE6 and Firefox tests, but IE7 is correct!

Important can be correctly explained, and the page will not be displayed as required! After searching, find a good hack Method for IE7.

"* + Html" is used, and now IE7 is used for browsing. It should be okay.

  

You can write a CSS file as follows:

# Example {color: #333;}/* Moz */

* Html # example {color: #666;}/* IE6 */

* + Html # example {color: #999;}/* IE7 */

  

The font color in Firefox is displayed as #333, the font color in IE6 is displayed as #666, And the font color in IE7 is displayed as #999,

They do not interfere with each other.

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.