IE and FireFox on the CSS summary of the problem of inadequate support

Related Tags:

  Note: The following issue only for IE6 and below versions, and the following FireFox2.0.3 version, in the follow-up could be improved version, the author did not make further tests. 

  [] Introduction to the development of css 2.0 browser Although manufacturers have been strongly supported and in many respects, there is still insufficient information and did not fully standardized.    Web site designers now commonly used methods or Hack CSS CSS document prepared by the two solutions of different browser compatibility issues.    Following will be encountered in peacetime, when they were reading books, and the corresponding solutions to a simple summary.    Learning their allies hope will give some enlightenment, we also hope that the collective wisdom, will comment on the issue and found their own solutions written jointly study and improvement. 

  1, Box Model: 
  A Width of the calculation. 
  In the CSS standards, a box model includes four areas, namely: content, the Margin (padding), frame (border), and from the outside (margin).    Width and width of the calculation, CSS has its standards.    But in fact, different browser performance are different.    For example, 
  Firefox (FF) is accurate according to CSS standards: width as the width of the content, that is to say: 
  Layer width = width + Padding (left and right) + border-width; 
  And IE put width as the width of the entire layer: 
  Content width = width - padding - border-width; 

  B, IE margin in the double issue. 
  When the father of the use of Float time, the margin of sublayer will be doubled in the FireFox does not exist in this phenomenon. 

  <DOCTYPE html PUBLIC "- / / w3c / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  <html Xmlns="http://www.w3.org/1999/xhtml"> 
<head>
  <meta Http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  <title> Untitled Document </ title> 
<style>
  . Outer ( 
  Width: 500px; 
  Height: 200px; 
  Background: # 000; 
  ) 
  . Inner ( 
  Float: left; 
  Width: 200px; 
  Height: 100px; 
  Margin: 5px; 
  Background: # fff; 
  ) 
  </ Style> 
  </ Head> 
<body>
  <div Class="outer"> 
  <div Class="inner"> </ div> 
  </ Div> 
  </ Body> 
  </ Html> 

  Above code in IE browser can be found in a white box from the left side of the Border is twice. 
  Solutions: in the definition of inner inside add display: inline; attributes. 
  Reference code: box model on a range of issues 
  C, a high degree of不适应box problem. 
  When lining changes in target height, the Height of the outer object can not be automatically adjusted, in particular the use of the inner margin and padding object attributes of times.    At the same time the problem exists in IE / Firefox / Mazilla in. 

  <DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  <html Xmlns="http://www.w3.org/1999/xhtml"> 
<head>
  <meta Http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  <title> Untitled Document </ title> 
<style>
  . Outer ( 
  Background: # FFFF00; / * yellow frame used as a Background * / 
  ) 
  . Inner ( 
  Margin-top: 20px; 
  Margin-bottom: 20px; 
  Text-align: center; 
  Background: # 0000FF; / * internal use blue box * / 
  Color: # FFFFFF; 
  ) 
  . Box ( 
  Background-color: # 66FF99; / * this as a reference point * / 
  ) 
  </ Style> 
  </ Head> 
<body>
  <div Class="box"> upper </ div> 
  <div Class="outer"> 
  <div Class="inner"> object in the content of </ div> 
  </ Div> 
  <div Class="box"> lower </ div> 
  </ Body> 
  </ Html> 

  Preview when the code above can be found, the outer part of the upper and lower left another 20 px space, and this is the definition of inner margin-top and bottom-margin value.    Although in the outer inner internal, but outer space has not increased share (through its background Color can be seen). 
  Solutions: (1) defined in the outer ouer style padding or border, so it can be to re-calculate their outer level.    Such as: 

  . Outer ( 
  Background: # FFFF00; / * yellow frame used as a background * / 
  Border: 1px solid # fff; 
  ) 

  1 px white frame users in the invisible white background.    However, if the value of the use of border, we must specify the type of frame, solid or dotted otherwise FireFox shows that, on the upper and lower margins become 0. 
  (2) before a higher requirements in the design of the programme, 1 px have an impact on the error.    And could therefore be initiated from the internal ouer to add two empty div objects, and its high degree of 0 px to solve the problem. 

  . Clear-div ( 
  Height: 0px; 
  Overflow: hidden; 
  ) 
  <div Class="box"> upper </ div> 
  <div Class="outer"> 
  <div Class="clear-div"> </ div> 
  <div Class="inner"> object in the content of </ div> 
  <div Class="clear-div"> </ div> 
  </ Div> 
  <div Class="box"> lower </ div> 

  Li above reference "site layout Record" 259 related solutions.    Found in the actual definition of clear-div data for the overflow: hidden;, will be displayed in Dreamweaver is not normal.    Browser to Display correctly. 
  (3) There are a number of internal div outer layer elements, and use of float: left; time, the above solutions are invalid.    At this point in the outer div add overflow attributes, in the lining at the same time add a div Finally, the use of Clear at the same time: both attributes.    Code as follows: 

  <DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  <html Xmlns="http://www.w3.org/1999/xhtml"> 
<head>
  <meta Http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  <title> Untitled Document </ title> 
<style>
  . Outer ( 
  Width: 600px; 
  Background: # 000; 
  Overflow: auto; / * add here * / 
  ) 
  . Inner1 ( 
  Display: inline; / * in IE to prevent a double error margin * / 
  Float: left; 
  Width: 200px; 
  Height: 100px; 
  Margin: 5px; 
  Background: red; 
  ) 
  . Inner2 ( 
  Display: inline; / * in IE to prevent a double error margin * / 
  Float: left; 
  Width: 200px; 
  Height: 100px; 
  Margin: 5px; 
  Background: yellow; 
  ) 
  . Clear ( 
  Clear: both; / * this is also a must * / 
  ) 
  </ Style> 
  </ Head> 
<body>
  <div Class="outer"> 
  <div Class="inner1"> </ div> 
  <div Class="inner2"> </ div> 
  <div Class="clear"> </ div> / * Add this to a * / 
  </ Div> 
  </ Body> 
  </ Html> 

  Reference article: CSS: IE and Firefox features of the CSS-compatible 




Related articles:

Destination establishment - from entry to the master - skills chapter
  1.    ICO characteristics    Each page always wanted to see the good in the preservation of its collection folder go beyond convenience, but a long time, too many links on the dazzling, no way, cut!    You do not want their own web pages have been such a fate?&...
Getting Started
  Author: Builder.com    Tuesday, March 23 2004 3:03 PM    Previously, the creation of a Web page for the printer-friendly version of a means to design the layout and format changes have been separate pages, so that it can be in print when the results are satisfactory.&nbs...
Flash in the mouse painting skills
  Prologue: the Internet so much fun watching the colorful Flash, I believe that many of my friends would like to have their own personally generated animation aspirations.    But we and the majority of people did not learn painting, there is always a lot of ideas was unable to expres...
PopMenu-level direction of the pop-up menu (DIV + CSS + JS)
  According alistapart POPMENU this adaptation of the articles than using DW, hidden layer method should be simple.    In IE6.0 IE5.X Firefox NS can correct that only rarely used the JS code, as long as the use <ul> </ ul> parts can be inserted where needed, the resolutio...
Web editors realize the performance of commonly used methods
  In the development of web pages when we often encounter some of the demand will be, if we do not know, maybe half will haunt us.    In fact, they are very simple to achieve, as we look at these with a commonly used method editorial page.    Cancel the middle text  ...