使Selectivizr工作的麻烦

时间:2011-04-30 07:31:54

标签: css internet-explorer css3 css-selectors selectivizr

即使有一个非常简单的页面,我也很难让Selectivizr工作。我做错了什么?

http://jiewmeng.kodingen.com/playground/selectivr.html

<html>
<head>
    <link rel="stylesheet" href="selectivr.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.1/mootools-yui-compressed.js"></script>
    <!--[if (gte IE 6)&(lte IE 8)]>
      <script src="selectivizr.js"></script>
    <![endif]--> 

</head>

<body>
    <h1>Hello World</h1>
    <p>Paragraph 1</p>

    <p>Paragraph 2</p>
    <p>Paragraph 3</p>
    <p>Paragraph 4</p>
    <p>Paragraph 5</p>
    <p>Paragraph 6</p>
</body>
</html>

CSS

p:nth-child(2n+2) { color: red }

2 个答案:

答案 0 :(得分:4)

Selectivizr仅在您的页面处于严格模式时才有效。因为你没有给你的页面doctype declaration,它在Quirks模式下加载,这意味着Selectivizr没有加载。

只需在打开<!DOCTYPE html>标记之前添加html,然后选择Selectivizr。

答案 1 :(得分:3)

您可能希望将链接添加到selectivizr将要执行的现有css。

以下是您应该在案例中加入的完整代码:

    <!--[if (gte IE 6)&(lte IE 8)]>
      <script type="text/javascript" src="/js/selectivizr/selectivizr.js"></script>
      <noscript><link rel="stylesheet" href="selectivr.css" /></noscript>
    <![endif]-->

还有其他两个已知问题:

  • 在本地工作,无法正常工作
  • 同时使用PIE.htc,如果您已取消注释它。

希望它有所帮助!祝你好运。