0

我正在使用一些在 CSS 2.1 中不支持的 CSS 属性。例如,-moz-border-radius, box-shadow, zoom, filter,.... 让我无法通过 CSS 验证。

那么有什么技术可以让 CSS 验证器忽略它们吗?

4

1 回答 1

1

对于 Microsoft Propreitary attributes ,您可以通过以下方式将它们保存在条件注释中:

<!--[if IE 6]>
<style type="text/css">
    /* Use all the non-standard Microsoft Propreitary attributes */
    body {zoom: 1; filter: none;}
</style>
<![endif]-->

如果您在样式表中使用东西,那么您可以这样做:

<!--[if IE 6]>
<link rel="stylesheet" href="ie6.css" type="text/css" />
<![endif]-->

这在 W3C 中得到了完美验证。使用此代码检查:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Untitled Document</title>
        <!--[if IE 6]>
        <style type="text/css">
            /* Use all the non-standard Microsoft Propreitary attributes */
            body {zoom: 1; filter: none;}
        </style>
        <![endif]-->
    </head>

    <body>

    </body>
</html>

通过直接输入验证:http: //validator.w3.org/#validate_by_input

对于其他人,您可以为供应商扩展设置一个选项,以仅在 CSS 验证器中显示警告。

于 2012-06-27T04:26:39.523 回答