- 谷歌 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 中呈現顯示,如下所示 −
廣告