虽然要尽量少用,但是还是要记住这些CSS Hack

color:blue; // 所有浏览器
color:brown\9; // 所有IE浏览器
+color:red; // IE7
_color:green; // IE6

 

#color:red; /* IE7 */
_color:green; /* IE6 */
*color:yellow; /* for all IE */


background:blue; /*Firefox 背景變藍色*/

background:red \9; /*IE8 背景變紅色*/

*background:black; /*IE7 背景變黑色*/

_background:orange; /*IE6 背景變橘色*/

 

*background:green !important; /*IE7 背景變綠色*/

*background:orange; /*IE6 背景變橘色*/


 

 

<!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
{
display: none;
}
/* Opera */
html:first-child #opera
{
display: block;
}
/* IE 7 */
html > body #ie7
{
*display: block;
}
/* IE 6 */
body #ie6
{
_display: block;
}
/* Firefox 1 - 2 */
body:empty #firefox12
{
display: block;
}
/* Firefox */
@-moz-document url-prefix()
{
#firefox { display: block; }
}
/* Safari */
@media screen and (-webkit-min-device-pixel-ratio:0)
{
#safari { display: block; }
}
/* Opera */
@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>

posted @ 2011-06-30 15:28  qdsang  阅读(324)  评论(0编辑  收藏  举报