We will inevitably encounter browser compatibility problems when making pages, especially IE6. How can we be compatible with all browsers? The answer is CSS hack.
The followingCodeIt is some common CSS hack I have compiled myself. I hope it will help you.
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < Html Xmlns = "Http://www.w3.org/1999/xhtml" XML: Lang = "En" > < Head > < Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" /> < Meta HTTP-equiv = "X-UA-compatible" Content = "Ie = emulateie7" /> < Title > CSS hack </ Title > < Style Type = "Text/CSS" > . Demo { Width : 100px ; Height : 100px ; Border : 5px solid orange ; } . Demo1 { Background : Black ; /* For all */ } . Demo2 { Background : Green \ 9 ; /* For IE */ } . Demo3 { Background : Yellow \ 0 ; /* For IE8 */ } . Demo4 { * Background : Blue ; /* For IE7, IE6 */ } . Demo5 { _ Background : Red ; /* For IE6 */ } </ Style > </ Head > < Body > < Div Class = "Demo demo1" > </ Div > < BR /> < Div Class = "Demo demo2" > </ Div > < BR /> < Div Class = "Demo demo3" > </ Div > < BR /> < Div Class = "Demo demo4" > </ Div > < BR /> < Div Class = "Demo demo5" > </ Div > </ Body > </ Html >
There are also some CSS hack that I haven't used to list, such as chrome and opera. We usually cannot use these methods.
Tested browsers: IE6, IE7, IE8, ie9, Firefox, Google, Safari
PS: The best csser is compatible with all browsers without CSS hack. I also recommend that you avoid using CSS hack as much as possible. However, there is no way to deal with IE 6 (IE7), which is often entangled in 1 or 2 pixels. Otherwise, our tests won't pass, project offline --