微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

HTML – 包含的原因是什么

我发现使用AMP需要以下 CSS boilerplate code.它有什么作用?
<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>

任何人都可以知道在AMP页面中包含上述css代码的原因吗?

我可以写< style amp-boilerplate =“amp-boilerplate”>而不是<样式amp-boilerplate> ?

解决方法

Can anyone kNow the reason for including above css code in AMP pages ?

代码本身用于隐藏页面,直到完全呈现为止,然后将其淡入以提供更高的感知性能指标.如果您询问标签本身,那么Google将在内部使用< style amp-boilerplate>来命令解析DOM和CSSOM.

Can I write < style amp-boilerplate=”amp-boilerplate”> instead of < style amp-boilerplate> ?

是的,您可以将标记名称作为标记的值,它仍将通过AMP验证.但是,建议不要这样做,因为AMP规范可能随时发生变化,这可能不再有效.

我已通过在实时页面上使用AMP验证工具并在内部同时使用NodeJS验证器和Python验证器来确认这一点.

原文地址:https://www.jb51.cc/html/226423.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐