AMP页面是网页;页面及其元素的任何样式都是使用常见的CSS属性完成的。在<head>中嵌入的样式表中使用类或元素选择器的样式元素,<style amp-custom></style>,如下代码演示,注意:amp禁止引入除字体外的css文件<link rel=”stylesheet”>
<style amp-custom>
/* any custom style goes here */
body {
background-color: white;
}
amp-img {
background-color: gray;
border: 1px solid black;
}
</style>
每个AMP页面只能有一个单一的嵌入样式表和内联样式,但有些选择器你不允许使用:
AMP在页面布局元素时遵循更严格的规则。在普通的HTML页面上,几乎完全使用CSS来布局元素。但出于性能原因,AMP要求所有元素都有明确的大小设置从一开始。
参考资料 https://amp.dev/documentation/guides-and-tutorials/develop/style_and_layout/style_pages/?format=websites