Home > Article > Web Front-end > div css compatibility issues learning summary_html/css_WEB-ITnose
hack model
firefox ie7 ie6
left: *left: _left:
Note: IE can recognize *; standard readers (such as FF) cannot recognize *;
IE6 can recognize *, but not !important, ballet shoes,
IE7 can recognize *, but it can also recognize !important;
FF cannot recognize *, but it can recognize !important; IE6 IE7 FF
IE6 supports the underscore "_", but neither IE7 nor Firefox supports the underscore.
!important priority
margin-left:20px !important;
margin-left:10px;
ie7 gives priority to the first item, and ie6 does not support priority, so the first item is ignored , click the second item to display.
IE8 web design CSS compatibility
Other compatibility skills (troublesome again)
1. Setting padding on a div under FF will cause the width and height to increase, but IE will not. (can be solved with !important)
2 , centering problem.
1). Vertically center. Set line-height to the same height as the subsequent div, and then pass vertical-align: middle. (Note that the content does not need to be wrapped.)
2). Horizontal center. margin: 0 auto; (of course not universal)
3, if you need to add styles to the content in the a tag, you need to set display: block; (common in navigation tags)
4, FF and The difference in IE's understanding of BOX leads to a 2px difference and problems such as double margins of divs set to float under IE.
5. The ul tag has list-style and padding by default under FF. It is best to declare it in advance, with Avoid unnecessary trouble. (common in navigation tags and content lists)
6, Do not set the height of the div as an external wrapper. It is best to add overflow: hidden. to achieve height adaptability.
7, About hand-shaped light. cursor: pointer. And hand is only applicable to IE.
Other compatibility skills
1 For the css style of firefox ie6 ie7
Nowadays, most of them use !important to hack, about The ie6 and firefox tests can display normally,
but ie7 can accurately explain !important, which will cause the page to be displayed out of click! Found a clue
A good hack method for IE7 is to use "* html". Now use IE7 to try it, and there should be no problem.
Now you can write a CSS like this:
#1 { color: #333; }
* html #1 { color: #666; }
* html #1 { color: # 999; }
Then the font color is displayed as #333 under Firefox, #666 under IE6, and #999 under IE7.
2 IC transaction network centering problem in css layout
The important style definitions are as follows:
body {TEXT-ALIGN: center;}
#center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; }
Explanation:
First define TEXT-ALIGN: center in the female element; the meaning of this is to center the content in the female element; this setting is enough for IE That's it.
But it cannot be centered in mozilla. The solution is to add "MARGIN-RIGHT: auto;MARGIN-LEFT: auto;" when setting the sub-element definition time
It should be noted that if you want to use this method to center the entire page, it is recommended Don't wrap it in one DIV. You can create several divs in sequence.
Just define MARGIN-RIGHT: auto;MARGIN-LEFT: auto; in each div. That's it.
3 Different descriptions of box models.
#box{ width:600px; //for ie6.0- width:500px; //for ff ie6.0}
#box{ width:600px!important //for ff width:600px; //for ff ie6.0 width :500px; //for ie6.0-}
4 Double interval for IC trading network floating ie
#box{ float:left; width:100px; margin:0 0 0 100px; //In this case, IE will generate a 200px gap display:inline; //Make the float invisible}
Let’s talk about the two elements block and inline in detail. The characteristics of the Block element are: it always starts on a new line, and the height, width, line height, and margins can all be controlled (block elements); the characteristics of the Inline element are: and other The elements are on the same line, Xinwang Technology,... cannot be controlled (inline elements);
#box{ display:block; //Inline elements can be simulated as block elements display:inline; //The result of achieving the same arrangement diplay:table;
5 IE takes the width and height of the answer
IE does not recognize the definition of min-, but in fact it takes the general Width and height should be used with min in mind. This answer is too big. If you only use width and height,
these two values will not change in ordinary browsers. If you only use min-width and min-height, there will be no change in IE. Set width and height.
For example, if you want to set a negative background image, this width is more important. To solve this problem, you can do this:
#box{ width: 80px; height: 35px;}html>body #box{ width: auto; height: auto; min-width: 80px; min-height: 35px;}
Minimum width in 6 pages
min-width is a very convenient CSS command. It can specify that the minimum width of an element cannot be less than a certain width, so as to ensure continuous accurate typesetting. But IE doesn’t recognize this,
But it actually uses the width as the minimum width. In order to make this command work on IE, you can put a