【问题标题】:AMP validation error: "The mandatory text inside tag 'head > style[amp-boilerplate]' is missing or incorrect."AMP 验证错误:“标签 'head > style[amp-boilerplate]' 中的强制文本缺失或不正确。”
【发布时间】:2019-01-16 06:14:13
【问题描述】:

我从here 复制并粘贴了强制代码。 这是来自页面来源:

  <style amp-boilerplate>
        body {
            -webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;
            -moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;
            -ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;
            animation: -amp-start 8s steps(1,end) 0s 1 normal both
        }

        @-webkit-keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }

        @-moz-keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }

        @-ms-keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }

        @-o-keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }

        @keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }
    </style>
    <noscript>
        <style amp-boilerplate>
            body {
                -webkit-animation: none;
                -moz-animation: none;
                -ms-animation: none;
                animation: none
            }
        </style>
    </noscript>

我仍然收到以下验证错误:

标签“head > style[amp-boilerplate]”内的强制文本是 缺失或不正确。 (看 https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md)

任何提示将不胜感激。

【问题讨论】:

  • 我没有经常使用 AMP,这是您在 head 标签内的唯一 style 标签吗?
  • 不,还有其他款式。我认为样式是允许的。如果没有,验证应该抱怨它。
  • 你能发布你其他style标签的要点吗?我认为他们缺少amp-custom 属性
  • 非常抱歉,但我意识到我复制了错误消息。我已经纠正了。感谢您在这里伸出援助之手。再次道歉。
  • 一点也不。很高兴你明白了。

标签: amp-html


【解决方案1】:

AMP 希望样板文件保持最小化。我刚刚将您的样板代码粘贴到 AMP Playground 文档中,并得到了与您完全相同的错误。

只是为了确认它是缩小版,我从你的帖子中缩小了你的样板,它起作用了。

<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>

编辑:

我做了更多的游戏。您可以在开始和结束标签之前和之后添加返回。似乎禁止向 CSS 本身添加任何回车或空格。

<style amp-boilerplate> 
    body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
 </style>
 <noscript>
   <style amp-boilerplate>
     body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}
   </style>
 </noscript>

Here is a link 解释 AMP 样板代码和允许的更改。基本上你只能在标签之后立即添加空格,你可以在已经存在的地方添加更多的空格。

AMP HTML 文档的 head 标记中必须包含以下样板文件。目前验证是通过正则表达式完成的,因此尽可能减少突变很重要。目前,允许的突变是:(1)在样式标签打开后立即插入任意空格,并在其关闭前立即插入; (2) 用任意空格替换下面sn-p中的任何空格。

【讨论】:

  • 非常感谢。我的第一个 AMP 页面现在只有一个验证错误。
  • 没问题!如果您遇到上一个错误,我很乐意提供帮助。
  • 非常感谢您的大力帮助。这是最后一个错误:stackoverflow.com/questions/51758230/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-30
  • 1970-01-01
相关资源
最近更新 更多