CSS Hack refers to embedding Code such as * and * html in CSS Code to facilitate independent control of the specific style of a browser. For example, some CSS Hack can only be identified by IE6 or IE7, while Firefox and other browsers cannot. This effectively controls the performance of CSS in different browsers and avoids writing multiple CSS files.
Here, Mango outlines common CSS Hack statements to help you better control page rendering:
1. * symbol
The IE browser can recognize the * symbol, but other browsers such as Firefox, Opera, and Chrome cannot recognize the * symbol.
For example, different text colors are displayed in Firefox and IE:
2 .! Important
IE7 not only recognizes * symbols, but also recognizes! Important, while IE6 can only recognize the former.
For example, different text colors are displayed in IE6 and IE7:
Combining browser features 1 and 2, you can identify Firefox, IE7, and IE6 in CSS and load different styles.
For example, three different text colors are displayed in Firefox, IE7, and IE6:
4. * html and * + html
IE core browsers can recognize * html and * + html, while Firefox and other non-IE core browsers cannot recognize.
For example, three different text colors are displayed in Firefox, IE7, and IE6: