Important compatibility differences between IE and FF browsers in the DIV+CSS layout

Source: Internet
Author: User

Some important differences between IE and the FF browser:

· IE does not have the same centering method as ff.

(1) An example of how the body can be centered in both IE and FF browsers:

[HTML]View Plaincopyprint?
  1. <html>
  2. <head>
  3. <title> Let the Body Container center in the browser </title>
  4. <link rel="stylesheet" type="text/css" href= "body_center.css">
  5. </head>
  6. <body>
  7. <div id="container">
  8. </div>
  9. </Body>
  10. </html>

BODY_CENTER.CSS file:

[HTML]View Plaincopyprint?
    1. Body {
    2. margin:0px;
    3. padding:0px;
    4. font:12px Arial, song body;
    5. Text-align:center;
    6. }
    7. #container {
    8. margin:0 Auto;
    9. width:90%;
    10. height:500px;
    11. Background:green;
    12. Text-align:left;
    13. }

· ie the default minimum height is 18px, the height of the 18px is the 18px display, and the FF browser specifies how many pixels to display.

(2) Examples:

[HTML]View Plaincopyprint?
  1. <html>
  2. <head>
  3. <title>ie Browser less than 18px height how normal display </title>
  4. <link rel="stylesheet" type="text/css" href= "llq_chayi.css">
  5. </head>
  6. <body>
  7. <div id="container">
  8. <div id="header">
  9. </div>
  10. <div class="Fenge"></div>
  11. <div id="main">
  12. </div>
  13. <div class="Fenge"></div>
  14. <div id="Footer">
  15. </div>
  16. </div>
  17. </Body>
  18. </html>


LLQ_CHAYI.CSS file:

[HTML]View Plaincopyprint?
  1. Body {
  2. margin:0px;
  3. padding:0px;
  4. font:12px song body;
  5. }
  6. #header {
  7. width:100%;
  8. height:80px;
  9. background:red;
  10. }
  11. #main {
  12. width:100%;
  13. height:600px;
  14. Background:yellow;
  15. }
  16. #footer {
  17. width:100%;
  18. height:80px;
  19. Background:blue;
  20. }
  21. . fenge {
  22. width:100%;
  23. height:10px;
  24. Clear:both;
  25. Overflow:hidden;
  26. }



• The default internal and external margins between browsers are different, body style Traditional Chinese medicine to margin and padding clear 0.

• Specifies the height of the chunk (that is, a div), ie automatically adjusts the height when the content of the chunk exceeds the height of the setting, and FF does not. Therefore, the way to solve this problem is not to specify the height of the block.

· Blocks in FF are displayed in accordance with the floating principle after using the floating attribute, but IE does not follow the floating principle. Therefore, in the use of floating chunks to remember the parent block also floating out of the document flow, clear floating, etc. to ensure browser compatibility.

· There is a big difference between IE and FF in the list attribute, the main manifestation is different from the default setting of the outer margin. Therefore, in order to ensure the compatibility of the two, the general UL style to the margin and padding first clear 0.

H1-h6 labels are not the same inside and outside margins, so the margin and padding are cleared 0.

• Border border width affects compatibility. In IE, width specifies the sum of the widths of the border plus the width of the content, and FF is only the width of the content not border. The way to solve this problem is to set the width value to two settings in the style sheet of an element, where the "widt= value!" Important "This is for FF, and this setting does not work for IE. However, setting a "width= value" for IE can be solved.

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.