外部 AMP 页面参考 css
AMP page reference for external css
如何在 amp 页面中添加外部 css 样式。
我用来包含 css 文件的这个标签。
<link href="css/cssnew.css" rel="stylesheet" media="screen">
它给出了以下错误:
标记 'link rel=stylesheet for fonts' 中的属性 'href' 设置为无效值 'css/cssnew.css'。 (参见 https://www.ampproject.org/docs/reference/spec#custom-fonts)
在 amp 文档中指定使用内联样式。
<style amp-custom>
//css code
</style>
但是如何将所有必需的 css 包含在此标签中,因为它有一定的限制。任何人都可以通过示例向我解释一下,因为我对 amp 页面完全陌生。提前谢谢你
无法添加外部样式表,例如css。它需要额外的网络请求,因此会减慢网站加载速度。
见 Basic howto.
您可以使用 PHP,但 css 不应超过 50kb。
您必须在头部部分包含此行
<?php readfile( getcwd() . "/amp.css"); ?>
CSS:
<style amp-custom>
body {
background-color: blue;
}
</style>
如何在 amp 页面中添加外部 css 样式。 我用来包含 css 文件的这个标签。
<link href="css/cssnew.css" rel="stylesheet" media="screen">
它给出了以下错误: 标记 'link rel=stylesheet for fonts' 中的属性 'href' 设置为无效值 'css/cssnew.css'。 (参见 https://www.ampproject.org/docs/reference/spec#custom-fonts)
在 amp 文档中指定使用内联样式。
<style amp-custom>
//css code
</style>
但是如何将所有必需的 css 包含在此标签中,因为它有一定的限制。任何人都可以通过示例向我解释一下,因为我对 amp 页面完全陌生。提前谢谢你
无法添加外部样式表,例如css。它需要额外的网络请求,因此会减慢网站加载速度。
见 Basic howto.
您可以使用 PHP,但 css 不应超过 50kb。 您必须在头部部分包含此行
<?php readfile( getcwd() . "/amp.css"); ?>
CSS:
<style amp-custom>
body {
background-color: blue;
}
</style>