IE6/IE7/IE8/Firefox/Chrome/Opera/Safari等主流浏览器hack写法
发布于 分类 Html5
396天前 有1个用户阅读过
本文来自我的百度空间博客详情
2007年开始使用的是 hi.baidu.com/udjy
后来百度空间强制升级为轻博客 hi.baidu.com/imnoco
2015年百度关闭了百度空间
<!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</title>
<style type="text/css">
body p
{
color:#3C0;
}
/* Opera */
html:first-child #opera
{
color:#333;
}
/* IE 7 */
html > body #ie7
{
*color:#666;
}
/* IE 6 */
body #ie6
{
_color:#0ff;
}
/* Firefox 1 - 2 */
body:empty #firefox12
{
color:#f0f;
}
/* Firefox */
@-moz-document url-prefix()
{
#firefox {color:#ff0; }
}
/* Safari chrome也在?*/
@media screen and (-webkit-min-device-pixel-ratio:0)
{
#safari {color:#00f;}
}
/* Opera */
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0)
{
head~body #opera {color:#0f0;}
}
/* ie8 */
#ie8\0{
color:#f00\0;
}
</style>
</head>
<body>
<p id="ie8">#f00红人IE 8</p>
<p id="opera">#0f0的Opera 7.2 - 9.5</p>
<p id="safari">#00f我是神奇的 Safari , chrome也在?</p>
<p id="firefox">#ff0我是崭新的 Firefox</p>
<p id="firefox12">#f0f我是陈年往事 Firefox 1 - 2 </p>
<p id="ie7">#666我很杯具 IE 7</p>
<p id="ie6">#0ff我是脑残 IE 6</p>
<!--tips:尽量别用hack,hack能救命,但hack不是个好东西!-->
<!--
#test{
color:red; /* 所有浏览器都支持 */
color:red !important;/* Firefox、IE7支持 */
_color:red; /* IE6支持 */
*color:red; /* IE6、IE7支持 */
*+color:red; /* IE7支持 */
color:red\9; /* IE6、IE7、IE8支持 */
color:red\0; /* IE8支持 */
}
body:nth-of-type(1) p{color:red;} /* Chrome、Safari支持 */
-->
</body>
</html>
-- The End --