简体   繁体   English

我为什么不能给 <html> 元素使用IE8中的属性或类选择器?

[英]Why can't I style the <html> element using attribute or class selectors in IE8?

See edit 见编辑

I am setting a data-page attribute on my <html> tag to the id of the current page. 我将<html>标记上的data-page属性设置为当前页面的ID。 So on my login page: 所以在我的登录页面上:

<html data-page="login">

For some reason, IE8 is not applying any styles like these: 出于某些原因,IE8并未应用以下任何样式:

[data-page="login"] { ... }
[data-page="login"] form { ... }
[data-page="login"] form input { ... }

Even though it is supposed to support the attribute selector. 即使它应该支持属性选择器。 If I change the data-page to an id, and select it using #login , IE8 works fine. 如果我将数据页更改为ID,然后使用#login选择它,则IE8可以正常工作。

Does anyone know how to fix this problem? 有谁知道如何解决这个问题? I'd like to keep the attribute selectors. 我想保留属性选择器。

EDIT: I've found that even trying to select with a class won't work, so it's not that. 编辑:我发现,即使尝试选择一个类也行不通,所以不是那样。 The problem seems to be that I cannot set styles on the <html> element at all in IE8. 问题似乎是我根本无法在IE8中的<html>元素上设置样式。

好的,所以我是个傻瓜,但是对于任何偶然发现此问题的人(直到您意识到它都是超级神秘的),我忘记了我在html元素上使用了HTML5 Boilerplate样式的条件注释,因此该模板变量仅在非IE浏览器中附加到html元素。

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

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