添加样式
AMP 页面是网页——任何对页面及其元素的样式设置都是使用标准的 CSS 属性完成的。但是,AMP 要求所有 CSS 都包含在文档头部的一个自定义 style
标签中,称为 <style amp-custom>
。<style amp-custom>
标签必须位于文档的 <head>
内。如果需要,样式也可以内联定义。尝试将以下样式添加到您的页面
<style amp-custom>
h1 {
margin: 1rem;
}
body {
background-color: blue;
}
</style>
AMP 允许几乎所有 CSS,但有一些选择器必须避免。 在此处了解这些以及更多关于在 AMP 中设置样式的信息。
-
作者: @crystalonscript