CSS compatibility under IE and Firefox

Source: Internet
Author: User
Tags wrapper
1.DOCTYPE Influence CSS Processing


2.ff:div Set Margin-left, Margin-right is already centered when auto, IE not good


3.ff:body set text-align, Div needs to set Margin:auto (mainly margin-left,margin-right) to center


4.FF: Set padding, div will increase the height and width, but IE will not, it is necessary to use!important more set a height and width


5.FF: Support!important, IE is ignored, available!important for the FF special set style, it is noteworthy that the XXXX!important must be placed above another sentence


6.div Vertical Center problem: vertical-align:middle; Increase line spacing to be as high as the entire Div line-height:200px; Then insert the text and center it vertically. The disadvantage is to control the content do not change line


7.cursor:pointer can display cursor finger shape in IE FF at the same time, hand only IE can


8.FF: Links with border and background color, you need to set the Display:block, while setting float:left guarantee do not wrap. Refer to MenuBar, to set a and menubar height is to avoid the bottom of the display dislocation, if not set height, you can insert a space in the menubar.


9. In Mozilla Firefox and IE, the box model explains inconsistencies resulting in a 2px resolution: div{margin:30px!important;margin:28px}


Note that the order of the two margin must not write the reverse, according to the Czech Republic!important This property IE is not recognized, but other browsers can identify. So in the case of IE, the explanation is as follows: div{maring:30px;margin:28px}


Repeat the definition according to the last one to execute, so can not only write margin:xxpx!important;


10.ie5 and IE6 's box explain inconsistencies


IE5 under div{width:300px;margin:0 10px 0 10px;}

The width of the
div is interpreted as 300px-10px (right padding) -10px (left padding) The final div has a width of 280px, while the width on IE6 and other browsers is calculated in 300px+10px (right padding) +10px (left padding) =320px. At this point we can do the following modification Div{width:300px!important;width/**/:340px;margin:0 10px 0 10px}


about this/**/is what I do not understand, only know IE5 and Firefox support but IE6 do not support, if someone understand, please tell me, thanks! :)


11.UL label in Mozilla default is padding value, and in IE only margin have a value, so first define ul{margin:0;padding:0;


can solve most of the problems


Note:


1, Float div must be closed.


For example: (where Floata, FLOATB properties are already set to Float:left;) < #div id= "Floata" >


< #div id= "FLOATB" >


< #div id= "NOTFLOATC" >


here the NOTFLOATC do not want to continue to translate, but want to row down.


This code has no problem with IE, the problem is in FF. The reason is that NOTFLOATC is not a float label and the float label must be closed.


in < #div class= "FLOATB" >


< #div class= "NOTFLOATC" >


Plus < #div class= "clear" >


This div must pay attention to the declaration of location, must be placed in the most appropriate place, and must be with two of the float property of the div sibling, there can be no nested relationship, or you will produce an exception.


and define clear this style as follows:. clear{


Clear:both;}


in addition, in order to allow the height of automatic adaptation, to wrapper inside add Overflow:hidden;


When the box contains float, the height of automatic adaptation in IE invalid, this time should trigger IE layout private properties (Evil ie Ah!) Can be done with zoom:1, so that compatibility is achieved.


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


Overflow:hidden;


zoom:1;


margin:5px Auto;


2, margin double the question.

The Div
set to float will double the margin set under IE. This is a bug that IE6 all exist.

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


For example:


< #div id= "Imfloat" >


the corresponding CSS for


#IamFloat {


Float:left;


Margin:5px;/*ie understood as 10px*/


Display:inline;/*ie under the understanding of 5px*/}


3, on the inclusion relationship of the container


Many times, especially when there are parallel layouts in the container, such as three float Div, the width is easily problematic. In IE, the width of the outer layer is broken by a wider div inside. Be sure to use Photoshop or firework to measure pixel-level precision.


4, about the height of the problem (3lian material)


if you are adding content dynamically, it is best not to define it. The browser can scale automatically, however, if it is static content, the height is best set. (Sometimes it doesn't seem to go down automatically, don't know exactly what's going on)


5, the most ruthless means-!important;


If there is no way to solve some of the details of the problem, you can use this method. FF will automatically give priority to "!important", while IE will ignore. The following. tabd1{


Background:url (/res/images/up/tab1.gif) no-repeat 0px 0px!important; /*style for ff*/


Background:url (/res/images/up/tab1.gif) no-repeat 1px 0px; /* Style for IE */}


It is worth noting that the XXXX!important must be placed above another sentence, which has been mentioned above.


  


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.