这是我的首选方式。它提供了最大的控制。(注意:仅IE5-9支持条件语句。)
首先正确设置您的ie类
<!DOCTYPE html><!--[if lt IE 7]> <html > <![endif]--><!--[if IE 7]> <html > <![endif]--><!--[if IE 8]> <html > <![endif]--><!--[if gt IE 8]><!--> <html> <!--<![endif]--> <head>
然后,您可以仅使用CSS来创建样式异常,或者,如果需要,可以添加一些简单的Javascript:
(function ($) { "use strict"; // Detecting IE var oldIE; if ($('html').is('.lt-ie7, .lt-ie8, .lt-ie9')) { oldIE = true; } if (oldIE) { // Here's your JS for IE.. } else { // ..And here's the full-fat pre for everyone else }}(jQuery));


