朋友请帮我定义IE9的具体css规则?
例如像这样
例如像这样
- /* IE 6 fix */
- * html .twit-post .delete_note a { background-position-y: 2px; }
- * html .twit-post .delete_note a:hover { background-position-y: -14px; }
解决方法
注意接受的答案也是针对IE10。因此,为了更完整的列表:
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) and (min-resolution: .001dpcm) {
- // IE9 CSS
- .ie9{property:value;}
- }
IE 9及以上
- @media screen and (min-width:0) and (min-resolution: +72dpi) {
- // IE9+ CSS
- .ie9up{property:value;}
- }
IE 9和10
- @media screen and (min-width:0) {
- .ie910{property:value;}
- }
仅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; }
Javascript替代品
Modernizr runs quickly on page load to detect features; it then
creates a JavaScript object with the results,and adds classes to the
html element
Javascript:
- var b = document.documentElement;
- b.setAttribute('data-useragent',navigator.userAgent);
- b.setAttribute('data-platform',navigator.platform );
- b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');
添加(例如)以下到html元素:
- data-useragent='Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)'
- data-platform='Win32'
允许非常有针对性的CSS选择器,例如:
- html[data-useragent*='Chrome/13.0'] .nav{
- background:url(img/radial_grad.png) center bottom no-repeat;
- }
脚注
如有可能,请避免浏览器定位。识别并修复您识别的任何问题。支持progressive enhancement和graceful degradation.考虑到这一点,这是一个“理想的世界”场景,在生产环境中并不总是可以实现的,因此上述方法应该有助于提供一些好的选择。
归因/基本阅读