Sass API
概述 點此獲取本節網址
模組 點此獲取本節網址
一般情況下han-css/index.scss
直接匯入
@import '[node_modules]/han-css/index';
匯入需要的
// 「漢字標準格式」必要檔案
@import '[node_modules]/han-css/src/sass/var';
@import '[node_modules]/han-css/src/sass/api';
// Normalize.css
@import '[node_modules]/han-css/src/sass/locale/normalize';
// 本地樣式標準化模組
@import '[node_modules]/han-css/src/sass/locale';
// 文字設計模組
@import '[node_modules]/han-css/src/sass/typography';
// 高級排版功能模組(章節的編排、行的組成)
@import '[node_modules]/han-css/src/sass/typeset';
字體基型 @extend 點此獲取本節網址
字體基型 @extend
據
註
一般字體基型 @extend
@extend %han-[基型]-[語言文字變體];
搭配西文意大利體的字體基型 @extend
@extend %han-[基型]-italic-[語言文字變體];
註
或參見以下二表
漢字字體基型點此獲取本節網址
基型 | 繁體中文 | 簡體中文 | 日文 |
---|---|---|---|
黑體 | %han-sans-hant
| %han-sans-hans
| %han-sans-ja
|
黑體 意大利體 | %han-sans-italic-hant
| %han-sans-italic-hans
| %han-sans-italic-ja
|
宋體 | %han-serif-hant
| %han-serif-hans
| %han-serif-ja
|
宋體 意大利體 | %han-serif-italic-hant
| %han-serif-italic-hans
| %han-serif-italic-ja
|
楷體 | %han-cursive-hant
| %han-cursive-hans
| %han-cursive-ja
|
楷體 意大利體 | %han-cursive-italic-hant
| %han-cursive-italic-hans
| %han-cursive-italic-ja
|
西文等寬 黑體 | %han-mono-hant
| %han-mono-hans
| %han-mono-ja
|
因
西文字體基型點此獲取本節網址
基型 | 西文字體 |
---|---|
無襯線 | %han-sans
|
無襯線意大利體 | %han-sans-italic
|
襯線 | %han-serif
|
襯線意大利體 | %han-serif-italic
|
手寫 | %han-cursive
|
手寫意大利體 | %han-cursive-italic
|
等寬 | %han-mono
|
代碼示例點此獲取本節網址
.box {
@extend %han-mono-hans;
}
上方的.box
%han-mono-hans
[%han-mono-hans],
code:lang(zh-Hans),
[……],
.box {
font-family: "Biaodian Pro Sans GB", Menlo, Courier, "Han Heiti GB", monospace, monospace, sans-serif
}
覆蓋順序 點此獲取本節網址
在擁有相同繼承權重的同一選擇器上套用二個以上的字體基型 @extend
基型覆蓋優先級 | |
---|---|
高 | 西文等寬 |
楷體 | |
楷體 | |
宋體 | |
宋體 | |
黑體 | |
低 | 黑體 |
代碼示例點此獲取本節網址
.some-container {
@extend %han-cursive-italic-hant;
@extend %han-sans-hant;
}
.some-container-2 {
@extend %han-sans-hant;
@extend %han-cursive-italic-hant;
}
上述代碼中.some-container
.some-container-2
相應的 @mixin 點此獲取本節網址
使用字體基型 @mixin han-typeface-by-lang
@include han-typeface-by-lang( $typeface: [基型] );
// 意大利體
@include han-typeface-by-lang( $typeface: [基型]-italic );
代碼示例點此獲取本節網址
.entry {
@include han-typeface-by-lang( $typeface: cursive );
}
上方代碼同等於
.entry {
&:lang(zh),
&:lang(zh-Hant) {
@extend %han-cursive-hant;
}
&:lang(zh-Hans),
&:lang(zh-CN) {
@extend %han-cursive-hans;
}
&:lang(ja) {
@extend %han-cursive-ja;
}
&:lang(zh-Latn),
&:lang(ja-Latn),
&:not(:lang(zh)):not(:lang(ja)),
*:lang(zh-Latn),
*:lang(ja-Latn),
*:not(:lang(zh)):not(:lang(ja)) {
@extend %han-cursive;
}
}
章節的編排 點此獲取本節網址
章節的計數 點此獲取本節網址
若欲在非article
han-section-counter
@include han-section-counter( $toc: false );
參數說明點此獲取本節網址
$toc
-
使用目錄清單與否
預設關閉, 開啓後。 容器下類別為, .toc
ol
其後每增加一子清單元素, 即為下一級的標題名稱容器, 可置於長篇文章頂部, 方便跳轉及査閱, 。
示例請見測試範例頁
行的組成 點此獲取本節網址
着重號 點此獲取本節網址
強調em
text-emphasis
Sass 點此獲取本節網址
@include han-text-emphasis(
$posi: under,
$mark: circle,
$shape: filled,
$color: inherit,
$skip: true,
$extend: true
);
參數說明點此獲取本節網址
$posi
-
着重號的位置
可為字下, under
over
。 $mark
-
着重號符號
選項有圈, circle
點、 dot
雙圈、 double-circle
三角形、 triangle
芝麻點、 sesame
<string>
。 $shape
-
着重號形狀
填滿, filled
空心、 open、無
。 $color
-
着重號顏色
。 $skip
-
規避標點符號與否
需配合( ) 。 $extend
-
使用選擇器 @extend
可減縮生成的, 。
JavaScript ( 選用) 點此獲取本節網址
Han( context ).renderEm( selector )
參數說明點此獲取本節網址
context
-
套用着重號選擇器的範圍
預設為文件內容, body
。 selector
-
套用着重號的目標選擇器
支援, 。
啓用 web font 合字功能 點此獲取本節網址
在需要啓用
@extend %han-ligature;
行尾點號懸掛 點此獲取本節網址
見
直式注音符號 點此獲取本節網址
非行間注元素下
@extend %han-zhuyin;
Sass 變數彙整 點此獲取本節網址
以下是_han.sass
檔案路徑點此獲取本節網址
Web fonts
$han-font-path: './font/';
元素容器的選用點此獲取本節網址
根元素:root
$han-root: html;
文章區塊容器.article
.entry
#post
$han-article: article;
$han-mobile-device-width: 480px;
文字樣式點此獲取本節網址
$han-line-height: 1.3; // 全域行高(設置於根元素)
$han-article-line-height: 1.7; // 文章行高(設置於文章區塊容器)
文章區塊是否使用齊頭尾文字對齊
$han-article-justify: true;
文章區塊是否啓用
$han-section-counter: false; // 章節標題計數
$han-section-counter-toc: false; // 目錄計數
縮進字數
$han-indent: 2em;
$han-indent-md: 1em; // 行動裝置上的縮進
着重號相關設定
// 遇標點回避與否
$han-text-emphasis-skip: true;
// 着重號形狀
// `none` || `filled` || `open`
$han-text-emphasis-shape: filled;
// 着重號符號
// `dot` || `circle` || `double-circle` || `triangle` || `sesame` || <string>
$han-text-emphasis-mark: circle;
// 着重號位置
// `over` || `under`
$han-text-emphasis-posi: under;
// 着重號顏色
// `inherit` || <color>
$han-text-emphasis-color: inherit;
// 日文着重號樣式設定(同上)
$han-text-emphasis-shape-ja: filled;
$han-text-emphasis-mark-ja: sesame;
$han-text-emphasis-posi-ja: over;
$han-text-emphasis-color-ja: inherit;
行間注元素中
$han-zhuyin-size: .5;
文字設計點此獲取本節網址
// 繁體中文字體變體
// `default` || `CNS` || `GB`
$han-glyph-set-hant: default;
// 繁體中文標點字體
// `Pro` || `CNS` || `GB` || `simp`
$han-biaodian-hant: Pro;
// 簡體中文字體變體
// `default` || `GB`
$han-glyph-set-hans: GB;
// 簡體中文標點字體
// `Pro` || `CNS` || `GB` || `simp`
$han-biaodian-hans: GB;
西文預設字體
// 無襯線
$han-sans: 'Helvetica Neue', Helvetica, Arial;
// 襯線
$han-serif: Georgia, 'Times New Roman';
// 等寬
$han-mono: Menlo, Courier;
中文預設字體
$han-sans-zh: '';
$han-serif-zh: '';
$han-cursive-zh: '';
$han-mono-zh: $han-sans-zh;
行的組成點此獲取本節網址
各語言文字的行尾點號懸掛啓用與否
// 繁體中文
$han-hanging-hant: false;
// 簡體中文
$han-hanging-hans: true;
// 日語
$han-hanging-ja: true;