css hack 总结 包括ie6-11,chrome,opera,firefox

时间:2024-01-13 09:30:44
<!DOCTYPE html>
<html>
<head>
<title>Css Hack ie各版本 opera chrome safari firefox</title>
<meta charset=”utf-8″ />
<style>
#test
{
width:300px;
height:300px; background-color:blue; /*firefox*/
background-color:red\9; /*all ie*/
background-color:yellow\0; /*ie8*/
+background-color:pink; /*ie7*/
_background-color:orange; /*ie6*/
}
:root #test { background-color:purple\9; } /*ie9*/
@media all and (min-width:0px){ #test {background-color:black\0;} } /*opera*/
@media screen and (-webkit-min-device-pixel-ratio:0){ #test {background-color:gray;} } /*chrome and safari*/
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
#test { background-color:#00ff00 !important; } /* ie10 */
*::-ms-backdrop, #test { background-color:#00ffff !important; } /* ie11 */
}
</style>
</head>
<body>
<div id='test'>css hack 测试</div>
</body>
</html>