diff --git a/docs/part/component-code.html b/docs/part/component-code.html
index a41434acd36d64a6a5c3913e3ee3e25c5e662157..c05959ef08b540aa7a440249937913d995b2ed11 100755
--- a/docs/part/component-code.html
+++ b/docs/part/component-code.html
@@ -4,6 +4,12 @@
+ <code><code></code>
+ 通过 .code
来为任何内容应用与代码相同的等宽字体。
+
+
HelloCode();
+
+ <h1 class="code">HelloCode();</h1>
@@ -14,6 +20,7 @@
按 Ctrl + C 来复制示例代码,按 Ctrl + V 来粘贴代码。
+ 按 <kbd>Ctrl</kbd> + <kbd>C</kbd> 来复制示例代码,按 <kbd>Ctrl + V</kbd> 来粘贴代码。
@@ -24,8 +31,38 @@
+ <pre><code><p>Hello world!</p></code></pre>
还可以使用.pre-scrollable
- class,其作用是设置max-height为350px,并在垂直方向展示滚动条。
+ class,其作用是设置 max-height
为 350px
,并在垂直方向展示滚动条。
+
+
// 这是一段较长的代码
+// 用来演示 .pre-scrollable
+// 当代码行数超出时会出现垂直滚动条
+// ============================================================================================================
+
+function test() {
+ var x = 1;
+ var y = 2;
+
+ var z1 = x*x + 2*x + 1;
+ var z2 = y*y + 2*y + 1;
+ var z = z1*z1 + z2*z2;
+
+ var o = z*z + 2*z + 1;
+ var p = (o/2 - z*z + 1)/o;
+ var q = (o + p)/z;
+
+ console.log(x);
+ console.log(y);
+ console.log(z);
+ console.log(q);
+}
+
+test();
+
+ <pre class="pre-scrollable">
+...
+</pre>
@@ -34,9 +71,9 @@
代码高亮是通过根据代码语言语法给代码中的单词、字符标记为不同颜色来显示的方法。代码高亮能大大提高代码的查阅体验。在web界面加上代码高亮非常容易,在产品中如需要向用户展现代码应该使用代码高亮。
- 这里推荐的方案是Google Code Prettify实现代码高亮。Google Code Prettify能够自动识别代码语言类型并正确应用语法高亮。
- 下面是一个php文件的示例:
+ 这里推荐的方案是 Google Code Prettify 实现代码高亮。Google Code Prettify能够自动识别代码语言类型并正确应用语法高亮。
+ 下面是一个 php 文件的示例:
<!doctype html>
<html lang="en">
@@ -50,6 +87,13 @@
</body>
</html>
+ <!-- 为 pre 增加 prettyprint CLASS -->
+<pre class="prettyprint linenums">
+...
+</pre>
+
+// 页面导入 prettify.js 后调用 window.prettyPrint 方法来初始化代码高亮效果
+window.prettyPrint();