- 谷歌 AMP 教程
- 谷歌 AMP - 首页
- 谷歌 AMP - 概述
- 谷歌 AMP - 简介
- 谷歌 AMP - 图片
- 谷歌 AMP - 表单
- 谷歌 AMP - iframe
- 谷歌 AMP - 视频
- 谷歌 AMP - 按钮
- 谷歌 AMP - Timeago
- 谷歌 AMP - 数学公式标记
- 谷歌 AMP - 适应文本
- 谷歌 AMP - 日期倒计时
- 谷歌 AMP - 日期选择器
- 谷歌 AMP - 故事
- 谷歌 AMP - 选择器
- 谷歌 AMP - 链接
- 谷歌 AMP - 字体
- 谷歌 AMP - 列表
- 谷歌 AMP - 用户通知
- 谷歌 AMP - 下一页
- 谷歌 AMP - 属性
- 样式和自定义 CSS
- 谷歌 AMP - 动态 CSS 类
- 谷歌 AMP - 操作和事件
- 谷歌 AMP - 动画
- 谷歌 AMP - 数据绑定
- 谷歌 AMP - 布局
- 谷歌 AMP - 广告
- 谷歌 AMP - 分析
- 谷歌 AMP - 社交小部件
- 谷歌 AMP - 媒体
- 将 HTML 页面转换为 AMP 页面
- 谷歌 AMP - 基本语法
- 谷歌 AMP - 验证
- 谷歌 AMP - 缓存
- 谷歌 AMP - 自定义 JavaScript
- 谷歌 AMP - 跨域资源共享
- 谷歌 AMP 有用资源
- 谷歌 AMP - 快速指南
- 谷歌 AMP - 有用资源
- 谷歌 AMP - 讨论
谷歌 AMP - 数学公式标记
使用 MathML,我们可以展示数学公式。在本章节中,让我们通过一个工作示例了解如何使用 MathML 并计算几个数学公式以显示它们。
要使用 MathML,我们需要包含以下 javascript 文件 −
<script async custom-element = "amp-mathml" src = "https://cdn.ampproject.org/v0/amp-mathml-0.1.js"> </script>
MathML AMP 标记
MathML amp 标记的格式如下所示 −
<amp-mathml layout = "container"
data-formula = "\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]">
</amp-mathml>
请注意,data-formula 是公式所在的必备属性。
示例
让我们通过一个示例来更好地了解此标记。
<!doctype html>
<html amp lang = "en">
<head>
<meta charset = "utf-8">
<script async src = "https://cdn.ampproject.org/v0.js"></script>
<title>Google AMP - MathML</title>
<link rel = "canonical" href = " http://example.ampproject.org/article-metadata.html">
<meta name = "viewport" content = "width = device-width,minimum-scale = 1,initial-scale = 1">
<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>
<script async custom-element = "amp-mathml"
src = "https://cdn.ampproject.org/v0/amp-mathml-0.1.js">
</script>
</head>
<body>
<h1>Google AMP - MathML Example</h1>
<amp-mathml layout = "container"
data-formula = "\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]">
</amp-mathml>
</body>
</html>
输出
Amp-mathml 标记在执行时会在 iframe 中呈现显示,如下所示 −
广告