Document directory
- Difference between different browsers, CSS hack writing:
How to Write CSS hack
For example, to distinguish IE6 from Firefox, you can write as follows:
- <Style>
- Div {
- Background: green;/* For Firefox */
- * Background: red;/* For IE6 */
- }
- </Style>
- <Div> I saw red in IE6 and green in Firefox. </Div>
[XML]View plaincopy
- <Style> Div {Background: green;/* For Firefox */* Background: red; /* For IE6 */} </style> <div> I saw red in IE6 and green in Firefox. </Div>
Explanations:
In Firefox, the above CSS does not recognize the stuff with an asterisk *, so it is filtered out and ignored. The parsed result is: div {Background: Green}, so the background of this div is green.
In IE6, both background can be identified. The parsed result is: div {Background: green; Background: red;}, so according to the priority level, the red at the end has a high priority, so of course the background color of this div is red.
CSS hack: distinguishes IE6, IE7, and Firefox from different browsers. CSS hack Syntax:
Difference between IE6 and FF: Background: orange; * Background: blue;
Difference between IE6 and IE7: Background: Green! Important; Background: blue;
Difference between IE7 and FF: Background: orange; * Background: green;
Difference ff, IE7, IE6: Background: orange; * Background: Green! Important; * Background: blue;
Note: IE can recognize *; standard browsers (such as ff) cannot recognize *; IE6 can recognize *, but not! Important and IE7 can recognize * and also! Important; FF cannot recognize *, but can recognize it! Important;
|
IE6 |
IE7 |
FF |
* |
√ |
√ |
× |
! Important |
× |
√ |
√ |
Add another underscore "_",
IE6 supports underlines, while IE7 and Firefox do not.
So you can also distinguish IE6, IE7, and Firefox.
: Background: orange; * Background: green; _ Background: blue;
Note: No matter what method, the order of writing is Firefox's preface, IE7's writing in the middle, and IE6's writing at the end.