IE10 CSS Hack(順便聊聊IE11的CSS Hack) – WEB前端開發
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>無標題文檔</title> <!--[if !IE]><!--> <script> // 針對IE10 if (/*@cc_on!@*/false) { document.documentElement.className += ' ie' + document.documentMode; } // 針對IE11及非IE瀏覽器, // 因為IE11下document.documentMode為11,所以html標簽上會加ie11樣式類; // 而非IE瀏覽器的document.documentMode為undefined,所以html標簽上會加ieundefined樣式類。 if (/*@cc_on!@*/true) { document.documentElement.className += ' ie' + document.documentMode; } </script> <!--<![endif]--> <style type="text/css"> .ie10 .testclass { color: red } .ie11 .testclass { color: blue } .ieundefined .testclass { color: green } </style> </head> <body> <div class="testclass"> test text! </div> </body> </html> |