CSS Hack 区分 Opera @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {head~body #opera { display: block; }}
然后,全部合在一起便是 !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" html lang="en" head meta http-equiv="Content-Type" content="text/html; charset=utf-8" title CSS Browser Hacks - webjx.com /title style type="text/css" body p { display: none; } html:first-child #opera { display: block; }html body #ie7 { *display: block; }body #ie6 { _display: block; }body:empty #firefox12 { display: block; }
@-moz-document url-prefix() { #firefox { display: block; } } @media screen and (-webkit-min-device-pixel-ratio:0) { #safari { display: block; } }@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { head~body #opera { display: block; } } /style /head body p id="opera" 我来自 Opera 7.2 - 9.5 /p p id="safari" 神马是 Safari /p p id="firefox" 我来自 Firefox /p p id="firefox12" 我是你爷爷 Firefox 1 - 2 /p p id="ie7" 我是囧 IE 7 /p p id="ie6" 我是犀利哥 IE 6 /p /body /html CSS Hack 虽好且方便兼容各浏览器,但是通不过 W3C 验证,所以还得自己权衡是否有必要去使用 html教程