简体   繁体   English

IE9忽略CSS3:not()选择器

[英]CSS3 :not() selector ignored by IE9

CSS: CSS:

input:not([type=submit]):focus,
input:not([type=file]):focus,
textarea:focus {
    background: #f8f8f8;
    -webkit-box-shadow: 0 0 5px 0 rgba(67,67,67,0.3);
    box-shadow: 0 0 5px 0 rgba(67,67,67,0.3);
    outline-color:transparent;
    outline-style:none;
}

IE9 is ignoring input:not([type=file]):focus and styles its box-shadow, background and so on on the input file focus. IE9忽略input:not([type=file]):focus并设置其框阴影,背景等在输入文件焦点上的样式。

Any ideas whats wrong? 有什么想法怎么了?

EDIT: 编辑:

If its NOT supported: Why is IE9 styling it the like above? 如果不支持它:为什么IE9像上面那样样式? If it IS supported: Why is IE9 ignoring :not() ? 如果受支持:为什么IE9忽略:not()? and styling it like above? 和上面的样式一样?

IE9 certainly supports the :not selector - caniuse (as mentioned in comments) IE9当然支持:not选择器-caniuse (如注释中所述)

However... 然而...

Your CSS is not doing what you think. 您的CSS并没有按照您的想法做。

In your current code the second rule: 在您当前的代码中,第二条规则是:

input:not([type=file]):focus

overrides the first rule. 覆盖第一条规则。 So the properties will be applied to all input elements except file - but including submit - and in ALL browsers (not only IE9) 因此,这些属性将应用于除文件(但包括提交)以外的所有输入元素,并应用于所有浏览器(不仅限于IE9)

Instead you should chain the selectors like this: 相反,您应该像这样链接选择器:

input:not([type=submit]):not([type=file]):focus, 
textarea:focus {
    background: #f8f8f8;
    -webkit-box-shadow: 0 0 5px 0 rgba(67,67,67,0.3);
    box-shadow: 0 0 5px 0 rgba(67,67,67,0.3);
    outline-color:transparent;
    outline-style:none;
    color: pink;
}

Checkout this FIDDLE : 签出此FIDDLE

...You can see that the input of types submit and file won't get the styles applied on focus, however the input of type button will get the styles applied on focus. ...您可以看到类型为commit和file的输入不会将样式应用于焦点,但是类型按钮的输入将会将样式应用于焦点。

I tested it in IE9 and it works fine. 我在IE9中测试了它,效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM