1. Cursor:hand VS Cursor:pointer
Firefox does not support hand, but IE supports pointer
Workaround: use pointer uniformly
2. innertext works in IE, but not in Firefox.
Need textcontent.
Workaround:
if (Navigator.appName.indexOf ("explorer") >-1) {
document.getElementById (' element '). InnerText = "my text";
} else{
document.getElementById (' element '). Textcontent = "my text";
}
3. CSS Transparency
IE:filter:progid:DXImageTransform.Microsoft.Alpha (style=0,opacity=60).
ff:opacity:0.6.
4. Width and padding in CSS
Width widths in IE7 and FF do not include padding, and padding are included in Ie6.
5. FF and Iebox models explain inconsistencies resulting in a 2px difference
box.style{width:100;border1px;}
ie understood as Box.width =100
FF understood as Box.width = 100 + 1*2 = 102//plus Border 2px
Workaround:div{margin:30px!important;margin:28px;}
Note that the order of the two margin must not be written counter, IE does not recognize!important this attribute, but other browsers can be recognized. So under IE actually explains this: div{maring:30px;margin:28px}
Repeat definition is executed according to the last one, so it is not possible to write only margin:xxpx!important;
6. IE5 and IE6 's box explanations are inconsistent
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 width is 280px, and the width on IE6 and other browsers is calculated as 300px+10px (right padding) +10px (left padding) =320px. At this point we can make the following changes Div{width:300px!important;width/**/:340px;margin:0 10px 0 10px}
7. UL and OL list indent issues
Eliminate the UL, OL and other list of indentation, the style should be written as: list-style:none;margin:0px;padding:0px;
It is verified that in IE, setting margin:0px can remove the upper and lower left and right indent, blank and list number or dot of list, setting padding has no effect on style; in Firefox, setting margin:0px can only remove upper and lower whitespace, set padding:0 Only the left and right indents can be removed after PX, and List-style:none must be set to remove the list number or dot. In other words, in IE, only set margin:0px can achieve the final effect, and in Firefox must be set margin:0px, padding:0px and list-style:none three items to achieve the final effect.
8. Element horizontal Centering Problem
Ff:margin:0auto;
IE: Parent {text-align:center;}
9. Vertical center of DIV problem
Vertical-align:middle; Increase the line spacing as high as the entire DIV: line-height:200px, then insert the text and center vertically. The disadvantage is to control the content not to wrap.
10.
margin
double the problem
A div set to float doubles the margin set under IE. This is a bug that exists in a IE6. The solution is to add display:inline to this div;
For example:
<divid= "Imfloat" >
The corresponding CSS is
#imfloat {
Float:left;
Margin:5px;/*ie understood as 10px*/
Display:inline;/*ie under the 5px*/}
A. ie with width and height issues
IE does not recognize the definition of min-, but in fact it treats the normal width and height as a condition of min. This problem is big, if only with the width and height, the normal browser of these two values will not change, if only with Min-width and min-height, ie, the following is not set width and height.
For example, to set the background image, this width is more important. To solve this problem, you can:
#box {width:80px; height:35px;} Html>body #box {width:auto;height:auto; min-width:80px; min-height:35px;}
12. Minimum width of the page
As the previous problem, IE does not recognize min, to achieve the minimum width, the following methods can be used:
#container {min-width:600px;width:expression (document.body.clientwidth< 600?) "600px": "Auto");}
The first min-width is normal, but the width of line 2nd uses JavaScript, which only IE recognizes, which also makes your HTML document less formal. It actually achieves the minimum width by JavaScript's judgment.
Div floating IE text generates 3 pixel bug
The left object floats, the right side is positioned with the left margin of the outer patch, and the text within the right object is spaced 3px away from the left.
#box {float:left; width:800px;}
#left {float:left; width:50%;}
#right {width:50%;}
*html #left {margin-right:-3px;//This sentence is the key}
<div id= "box" >
<div id= "left" ><div id= "right" ></div>
The problem of IE hide and seek
When the div application is complex, there are some links in each column, and the div is prone to hide-and-seek problems.
Some content does not show up when the mouse selects this area is found content is indeed on the page.
WORKAROUND: Use Line-height attribute for #layout or use fixed height and width for #layout. The page structure is as simple as possible.
The div closure of the. float; clear float; Adaptive height
① Example:
The NOTFLOATC here do not want to continue panning, but want to go down the line. (where the properties of Floata and FLOATB have been set to float:left;)
This code is no problem in 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= "clear" > this div must pay attention to the location, and There must be no nesting relationship with two div siblings with the float attribute, or an exception will occur. And the clear style is defined as follows: . Clear{clear:both;}
② as an external wrapper div do not set dead height, in order to allow the height of self-adaptation , to wrapper inside add Overflow:hidden; When the box containing float, the height of adaptive under IE invalid, this time should trigger the layout of IE private property (Evil ie Ah!). ) with zoom:1; Can be done so that the compatibility is achieved.
For example a certain wrapper is defined as follows:
. Colwrapper{overflow:hidden; zoom:1; margin:5px Auto;}
③ for typography, the CSS description we use most probably is float:left. Sometimes we need to do a uniform background behind the float div in the n column, for example:
<div id= "Page" >
<div id= "left" ><div id= "center" ><div id= "right" >
</div>
For example, we want to set the page's background to blue, to achieve all three columns of the background color is blue, but we will find that with the left centerright is stretched downward, and page incredibly save the height of the same, the problem is because the page is not a float property, And our page is to be centered, cannot be set to float, so we should solve this:
<div id= "Page" >
<div id= "bg" style= "float:left;width:100%" >
<div id= "left" ><div id= "center" ><div id= "right" >
</div>
</div>
Then embed a float left and the width is 100% div resolved.
④ Universal Float closed ( very important!)
For the principle of clear float see [How to Clearfloats without Structural Markup], add the following code to the global CSS, add class= "Clearfix" to the div that needs to be closed, try Upset.
/* Clear Fix */
. clearfix:after {content: "."; display:block; height:0; clear:both;visibility:hidden;}
. clearfix {Display:inline-block;}
/* Hide from IE MAC */
. clearfix {Display:block;}
/* End Hide from IE Mac */
/* End of Clearfix */
Alternatively, set:. hackbox{display:table;//Display the object as a block-element-level table}
16. Highly non-adaptable
Height intolerance is when the height of the inner object changes, the outer height cannot be automatically adjusted, especially when the inner object uses margin or padding.
Cases:
#box {background-color: #eee;}
#box p {margin-top:20px;margin-bottom:20px; text-align:center;}
<div id= "box" >
The contents of the <p>p object </div>
Workaround: Add 2 empty div object CSS code {Height:0px;overflow:hidden;} to the P object. Or add the border attribute to the Div.
17.
IE6
There are voids in the film .
There are many tricks to fix this bug, either to change the layout of the HTML, or to set the IMG to Display:block or set the Vertical-align property to vertical-align:top/bottom/middle/ Text-bottom can all be solved.
18.
Text input Box
Plus vertical-align:middle;
<style type= "Text/css" >
<!--
Input {
width:200px;
height:30px;
border:1px solid red;
Vertical-align:middle;
}
-
</style>
Verified that the next version of IE is not applicable, and FF, Opera, Safari, Chrome are all ok!
When content in Li exceeds length, it is displayed as an ellipsis
This technique works with IE, Opera, Safari, Chrom Browser, FF temporarily not supported.
<style type= "Text/css" >
<!--
Li {
width:200px;
White-space:nowrap;
Text-overflow:ellipsis;
-o-text-overflow:ellipsis;
Overflow:hidden;
}
-
</style>
20. Why IE Cannot set scroll bar color in Web Standard
The solution is to replace body with HTML
<! doctypehtml Public "-//w3c//dtd XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<meta http-equiv= "Content-type" content= "text/html;charset=gb2312"/>
<style type= "Text/css" >
<!--
HTML {
Scrollbar-face-color: #f6f6f6;
Scrollbar-highlight-color: #fff;
Scrollbar-shadow-color: #eeeeee;
Scrollbar-3dlight-color: #eeeeee;
Scrollbar-arrow-color: #000;
Scrollbar-track-color: #fff;
Scrollbar-darkshadow-color: #fff;
}
-
21. Why can't I define a container with around 1px height?
IE6 This problem is due to the default row height, there are a number of techniques to solve:
Example: Overflow:hidden zoom:0.08 line-height:1px
16. How can I make the layer appear above flash?
The workaround is to set the flash to transparent
<paramname= "wmode" value= "Transparent"/>
22. Link (A-label) border and background
A link with border and background color, need to set Display:block, and set Float:left guarantee not wrap. Refer to MenuBar, 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.
23. Hover style does not appear after hyperlink access
The clicked Hyperlink style is not hover and active, many people should have encountered this problem, the solution is to change the order of CSS properties: l-v-h-a
Code:
<style type= "Text/css" >
<!--
A:link {}
a:visited {}
a:hover {}
a:active {}
-
</style>
Form label
This tag in IE, will automatically margin some margins, and in the FF margin is 0, so if you want to show consistency, so it is best to specify the margin and padding in the CSS, for the above two issues, my CSS is generally used first in the style Ul,form {margin:0;padding:0;}.
25. Attribute selector (this is not compatible, is a bug to hide CSS)
p[id]{}div[id]{}
This is hidden for IE6.0 and IE6.0 versions, FF and opera. There is a difference between the property selector and the child selector, the range of the sub-selector is reduced in form, the range of the property selector is larger, such as P[id], and all P tags have the same type of ID.
26. Why the text in FF cannot open the height of the container
The container of fixed height value in standard browser is not open like IE6, then I want to fixed height, and want to be able to be open how to set it? The way is to remove height setting min-height:200px; Here in order to take care of the IE6 do not know min-height can be defined as:
{
Height:auto!important;
height:200px;
min-height:200px;
}
Browser CSS compatibility issues small summary------Peng Kee (025)