这是媒体查询的集合,可让您针对任何版本的Internet Explorer(从IE6到IE11 +),Firefox,Chrome和Safari(编辑:还添加了Opera)执行此操作。
IE 6
* html .ie6 { property: value; }
要么
.ie6 { _property: value; }
IE 7
*+html .ie7 { property: value; }
要么
*:first-child+html .ie7 { property: value; }
IE 6和7
@media screen\9 {
.ie67 {
property: value;
}
}
要么
.ie67 { *property: value; }
要么
.ie67 { #property: value; }
IE 6、7和8
@media \0screen\,screen\9 {
.ie678 {
property: value;
}
}
IE 8
html>/**/body .ie8 { property: value; }
要么
@media \0screen {
.ie8 {
property: value;
}
}
IE 8标准模式
.ie8 { property /*\**/: value\9 }
IE 8,9和10
@media screen\0 {
.ie8910 {
property: value;
}
}
仅限IE 9
@media screen and (min-width:0\0) and (min-resolution: .001dpcm) {
// IE9 CSS
.ie9{
property: value;
}
}
IE 9以上
@media screen and (min-width:0\0) and (min-resolution: +72dpi) {
// IE9+ CSS
.ie9up {
property: value;
}
}
IE 9和10
@media screen and (min-width:0\0) {
.ie910 {
property: value\9;
} /* backslash-9 removes ie11+ & old Safari 4 */
}
仅限IE 10
_:-ms-lang(x), .ie10 { property: value\9; }
IE 10以上
_:-ms-lang(x), .ie10up { property: value; }
要么
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
.ie10up {
property:value;
}
}
IE 11(及更高版本)
_:-ms-fullscreen, :root .ie11up { property: value; }
Firefox(任何版本)
@-moz-document url-prefix() {
.ff {
color: red;
}
}
Firefox(仅Quantum / Stylo)
@-moz-document url-prefix() {
@supports (animation: calc(0s)) {
/* Stylo */
.ffStylo {
property: value;
}
}
}
Firefox旧版(Stylo之前的版本)
@-moz-document url-prefix() {
@supports not (animation: calc(0s)) {
/* Gecko */
.ffGecko {
property: value;
}
}
}
Webkit(Chrome和Safari,任何版本)
@media screen and (-webkit-min-device-pixel-ratio:0) {
property: value;
}
谷歌浏览器(29+)
@media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {
.chrome {
property: value;
}
}
Safari(7.1+)
_::-webkit-full-page-media, _:future, :root .safari_only {
property: value;
}
Safari(从6.1到10.0)
@media screen and (min-color-index:0) and(-webkit-min-device-pixel-ratio:0) {
@media {
.safari6 {
color:#0000FF;
background-color:#CCCCCC;
}
}
}
Safari(10.1+)
@media not all and (min-resolution:.001dpcm) {
@media {
.safari10 {
color:#0000FF;
background-color:#CCCCCC;
}
}
}
歌剧(12+)
@media (min-resolution: .001dpcm) {
_:-o-prefocus, .selector {
.opera12 {
color:#0000FF;
background-color:#CCCCCC;
}
}
}
歌剧(11岁及以下)
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {
.opera11 {
color:#0000FF;
background-color:#CCCCCC;
}
}
有关更多信息或其他媒体查询,请访问browserhacks.com网站和/或查看我撰写的有关此主题的博客文章。