PageRenderTime 64ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/en/css/typography.md

https://gitlab.com/Ltaimao/amazeui
Markdown | 454 lines | 382 code | 72 blank | 0 comment | 0 complexity | f75f99cd9141d01cca5d689318a20729 MD5 | raw file
  1. # Typography
  2. ---
  3. Many Designers like to use English rather than Chinese. One the reason is that Chinese typography is much harder to handle than English. There are so many different characters with different strokes in Chinese.
  4. There are few experience and conclusions about Chinese typography in web design for us to consult. Therefore, We did some setting on font for Chinese base on our own experience in Amaze UI.
  5. ## Font
  6. Amaze UI mainly use sans-serif fonts, and use monospace font for `<code>`, `<pre>` and some other elements.
  7. ### Font CSS
  8. ```css
  9. body {
  10. font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans","wenquanyi micro hei","Hiragino Sans GB", "Hiragino Sans GB W3", Arial, sans-serif;
  11. }
  12. ```
  13. - __Segoe UI__ - Windows UI Font( Used since Windows Vista);
  14. - __Helvetica Neue__ Font in iOS7 and OSX 10.10 UI ( Has some problems when using center align, so temporarily use `Lucida Grande` instead;
  15. - Some Windows users installed `Hiragino Sans GB W3`, which has some rendering problem on windows. So we put `Microsoft YaHei` in front of `Hiragino Sans GB W3`;
  16. - __FreeSans__ - Font in Linux distributions like Ubuntu.
  17. ### Font Utility Class
  18. In the implementation of Amaze UI, `font-family` only appear twice in Base style. We also don't recommend you to use too much `font-family` in your project, but you may use utility classes in Amaze UI instead.
  19. - `.am-sans-serif` __Sans serif font__ is the main font of Amaze UI.
  20. - `.am-serif` __Serif font__ is not used in Amaze UI.
  21. - `.am-kai` __Use serif for English text and numbers, and use Kai for Chinese characters__. The only difference between `.am-kai` and `.am-serif` is on the Chinese characters. Amaze UI use `.am-kai` in `<blockquote>`.
  22. - `.am-monospace` __monospace font__ is used in Amaze UI source code.
  23. This example shows the difference among these fonts.
  24. `````html
  25. <p>
  26. The quick brown fox jumps over the lazy dog. <br/>
  27. 千万不要因为走得太久,而忘记了我们为什么出发。 <br/>
  28. 千萬不要因為走得太久,而忘記了我們為什麼出發。
  29. </p>
  30. <p class="am-serif">
  31. The quick brown fox jumps over the lazy dog. <br/>
  32. 千万不要因为走得太久,而忘记了我们为什么出发。 <br/>
  33. 千萬不要因為走得太久,而忘記了我們為什麼出發。
  34. </p>
  35. <p class="am-kai">
  36. The quick brown fox jumps over the lazy dog. <br/>
  37. 千万不要因为走得太久,而忘记了我们为什么出发。 <br/>
  38. 千萬不要因為走得太久,而忘記了我們為什麼出發。
  39. </p>
  40. <p class="am-monospace">
  41. The quick brown fox jumps over the lazy dog. <br/>
  42. 千万不要因为走得太久,而忘记了我们为什么出发。 <br/>
  43. 千萬不要因為走得太久,而忘記了我們為什麼出發。
  44. </p>
  45. `````
  46. ```html
  47. <p>...</p>
  48. <p class="am-serif">...</p>
  49. <p class="am-kai">...</p>
  50. <p class="am-monospace">...</p>
  51. ```
  52. Technically, Kai is a cursive font, but we use `serif` for English in `.am-kai` because cursive fonts in English is too fancy to distinguish. The definition of 5 fonts can be found in [W3C Docs](http://www.w3.org/TR/CSS2/fonts.html#value-def-generic-family)。
  53. ### Webkit Anti-aliasing
  54. What's more, Webkit browsers use anti-aliasing when rendering, so Characters can be slightly thiner in Webkit browsers than other browsers.
  55. __2014.10.10 update:__`-moz-osx-font-smoothing` is added in Firefox for OSX since v25 to achieve the similar effect as Webkit.
  56. ```css
  57. body {
  58. -webkit-font-smoothing: antialiased;
  59. -moz-osx-font-smoothing: grayscale;
  60. }
  61. ```
  62. If you don't like it, please reset to the default smooth font.
  63. ```css
  64. body {
  65. -webkit-font-smoothing: subpixel-antialiased;
  66. -moz-osx-font-smoothing: auto;
  67. }
  68. ```
  69. `````html
  70. <h3>Anti-aliasing on <code>-webkit-font-smoothing: antialiased;</code></h3>
  71. <p>
  72. The quick brown fox jumps over the lazy dog. <br/>
  73. 千万不要因为走的太久,而忘记了我们为什么出发。 <br/>
  74. 千萬不要因為走得太久,而忘記了我們為什麼出發。
  75. </p>
  76. <br/>
  77. <div style="-webkit-font-smoothing: subpixel-antialiased;-moz-osx-font-smoothing: auto">
  78. <h3>Anti-aliasing off <code>-webkit-font-smoothing: subpixel-antialiased;</code></h3>
  79. <p>
  80. The quick brown fox jumps over the lazy dog. <br/>
  81. 千万不要因为走的太久,而忘记了我们为什么出发。 <br/>
  82. 千萬不要因為走得太久,而忘記了我們為什麼出發。
  83. </p>
  84. </div>
  85. `````
  86. ```html
  87. <h3>-webkit-font-smoothing: antialiased;</h3>
  88. <p>
  89. The quick brown fox jumps over the lazy dog. <br/>
  90. 千万不要因为走的太久,而忘记了我们为什么出发。 <br/>
  91. 千萬不要因為走得太久,而忘記了我們為什麼出發。
  92. </p>
  93. <br/>
  94. <div style="-webkit-font-smoothing: subpixel-antialiased; -moz-osx-font-smoothing: auto">
  95. <h3>-webkit-font-smoothing: subpixel-antialiased;</h3>
  96. <p>
  97. The quick brown fox jumps over the lazy dog. <br/>
  98. 千万不要因为走的太久,而忘记了我们为什么出发。 <br/>
  99. 千萬不要因為走得太久,而忘記了我們為什麼出發。
  100. </p>
  101. </div>
  102. ```
  103. Reference
  104. - [-webkit-font-smoothing](http://ued.ctrip.com/blog/wp-content/webkitcss/prop/font-smoothing.html)
  105. - [Better font-rendering on OSX](http://maximilianhoffmann.com/posts/better-font-rendering-on-osx)
  106. ### Font Links
  107. __Fonts in operating systems__
  108. - [List of Microsoft Windows fonts](http://en.wikipedia.org/wiki/List_of_Microsoft_Windows_fonts)
  109. - [List of typefaces included with OS X](http://en.wikipedia.org/wiki/List_of_typefaces_included_with_OS_X)
  110. - [Common fonts to all versions of Windows & Mac equivalents](http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html)
  111. - [OS XMavericks Fonts](http://support.apple.com/kb/HT5944?viewlocale=zh_CN&locale=zh_CN)
  112. - [OS XMountain Lion Fonts](http://support.apple.com/kb/HT5379?viewlocale=zh_CN&locale=zh_CN)
  113. - [iOS 7Fonts](http://support.apple.com/kb/HT5878?viewlocale=zh_CN&locale=zh_CN)
  114. - [iOS 6Fonts](http://support.apple.com/kb/HT5484?viewlocale=zh_CN&locale=zh_CN)
  115. - [Windows UI 设计文档](http://dev.windows.com/en-us/design)
  116. - [Supported UI Fonts in Windows Phone][wpfts]
  117. - [Typography | Android Developers](http://developer.android.com/design/style/typography.html)
  118. [wpfts]:http://msdn.microsoft.com/library/windows/apps/hh202920(v=vs.105).aspx#BKMK_SupportedUIFontsinWindowsPhone
  119. __Open source projects about Chinese typography_
  120. - [漢字標準格式印刷品般的漢字網頁排版框架](https://github.com/ethantw/Han)
  121. - [Entry.css - Configurable and readable Chinese text style sheet](https://github.com/zmmbreeze/Entry.css)
  122. ## Default Styles for Elements
  123. ### `<h1> - <h6>`
  124. `<h1> - <h6>` are bolded and given a margin; `<h1>` is `1.5` times larger than usual; `<h2>` is `1.25` times largerOthers are same as usual.
  125. `````html
  126. <h1>h1 Title 1</h1>
  127. <h2>h2 Title 2</h2>
  128. <h3>h3 Title 3</h3>
  129. <h4>h4 Title 4</h4>
  130. <h5>h5 Title 5</h5>
  131. <h6>h6 Title 6</h6>
  132. `````
  133. ```html
  134. <h1>h1 Title 1</h1>
  135. <h2>h2 Title 2</h2>
  136. <h3>h3 Title 3</h3>
  137. <h4>h4 Title 4</h4>
  138. <h5>h5 Title 5</h5>
  139. <h6>h6 Title 6</h6>
  140. ```
  141. ### `<p>`
  142. `````html
  143. <p>无论走到哪里,都应该记住,过去都是假的,回忆是一条没有尽头的路,一切以往的春天都不复存在,就连那最坚韧而又狂乱的爱情归根结底也不过是一种转瞬即逝的现实。</p>
  144. `````
  145. ```html
  146. <p>无论走到哪里,都应该记住,过去都是假的,回忆是一条没有尽头的路,一切以往的春天都不复存在,就连那最坚韧而又狂乱的爱情归根结底也不过是一种转瞬即逝的现实。</p>
  147. ```
  148. ### `<hr>`
  149. `````html
  150. <hr/>
  151. `````
  152. ```html
  153. <hr/>
  154. ```
  155. ### `<blockquote>`
  156. source is in `<small>` element.
  157. `````html
  158. <blockquote>
  159. <p>无论走到哪里,都应该记住,过去都是假的,回忆是一条没有尽头的路,一切以往的春天都不复存在,就连那最坚韧而又狂乱的爱情归根结底也不过是一种转瞬即逝的现实。</p>
  160. <small>马尔克斯 ——《百年孤独》</small>
  161. </blockquote>
  162. `````
  163. ```html
  164. <blockquote>
  165. <p>无论走到哪里,都应该记住,过去都是假的,回忆是一条没有尽头的路,一切以往的春天都不复存在,就连那最坚韧而又狂乱的爱情归根结底也不过是一种转瞬即逝的现实。</p>
  166. <small>马尔克斯 ——《百年孤独》</small>
  167. </blockquote>
  168. ```
  169. ### `<pre>`
  170. More details in [Code](/css/code)
  171. `````html
  172. <pre style="background-color:#f8f8f8;color:#555">window.addEventListener('load', function() {
  173. FastClick.attach(document.body);
  174. }, false);
  175. </pre>
  176. `````
  177. ```html
  178. <pre>window.addEventListener('load', function() {
  179. FastClick.attach(document.body);
  180. }, false);
  181. </pre>
  182. ```
  183. ### ul/ol
  184. __`<ul>`:__
  185. `````html
  186. <ul>
  187. <li>Item #1</li>
  188. <li>Item #2
  189. <ul>
  190. <li>Item #1</li>
  191. <li>Item #2
  192. <ul>
  193. <li>Item #1</li>
  194. <li>Item #2</li>
  195. </ul>
  196. </li>
  197. </ul>
  198. </li>
  199. <li>Item #3</li>
  200. <li>Item #4</li>
  201. </ul>
  202. `````
  203. ```html
  204. <ul>
  205. <li>...</li>
  206. <li>...
  207. <ul>
  208. <li>
  209. <ul>
  210. <li>...</li>
  211. </ul>
  212. </li>
  213. </ul>
  214. </li>
  215. </ul>
  216. ```
  217. __`<ol>`:__
  218. `````html
  219. <ol>
  220. <li>Item #1</li>
  221. <li>Item #2
  222. <ol>
  223. <li>Item #1</li>
  224. <li>Item #2
  225. <ol>
  226. <li>Item #1</li>
  227. <li>Item #2</li>
  228. </ol>
  229. </li>
  230. </ol>
  231. </li>
  232. <li>Item #3</li>
  233. <li>Item #4</li>
  234. </ol>
  235. `````
  236. ```html
  237. <ol>
  238. <li>...</li>
  239. <li>...
  240. <ol>
  241. <li>
  242. <ol>
  243. <li>...</li>
  244. </ol>
  245. </li>
  246. </ol>
  247. </li>
  248. </ol>
  249. ```
  250. ### `<dl>`
  251. `````html
  252. <dl>
  253. <dt>响应式网页设计</dt>
  254. <dd>自适应网页设计(英语:Responsive web design,通常缩写为RWD)是一种网页设计的技术做法,该设计可使网站在多种浏览设备(从桌面电脑显示器到移动电话或其他移动产品设备)上阅读和导航,同时减少缩放、平移和滚动。</dd>
  255. <dt>响应式网页设计(RWD)的元素</dt>
  256. <dd>采用 RWD 设计的网站 使用 CSS3 Media queries,即一种对 @media 规则的扩展,以及流式的基于比例的网格和自适应大小的图像以适应不同大小的设备。</dd>
  257. </dl>
  258. `````
  259. ```html
  260. <dl>
  261. <dt>响应式网页设计</dt>
  262. <dd>自适应网页设计(英语:Responsive web design,通常缩写为RWD)是一种网页设计的技术做法,该设计可使网站在多种浏览设备(从桌面电脑显示器到移动电话或其他移动产品设备)上阅读和导航,同时减少缩放、平移和滚动。</dd>
  263. <dt>响应式网页设计(RWD)的元素</dt>
  264. <dd>采用 RWD 设计的网站 使用 CSS3 Media queries,即一种对 @media 规则的扩展,以及流式的基于比例的网格和自适应大小的图像以适应不同大小的设备。</dd>
  265. </dl>
  266. ```
  267. ### `<table>`
  268. This is the style after normalize. Find more details in [Table Component](/css/table).
  269. `````html
  270. <table>
  271. <caption>Title</caption>
  272. <thead>
  273. <tr>
  274. <th>Head #1</th>
  275. <th>Head #2</th>
  276. <th>Head #3</th>
  277. </tr>
  278. </thead>
  279. <tbody>
  280. <tr>
  281. <td>Data #1</td>
  282. <td>Data #2</td>
  283. <td>Data #3</td>
  284. </tr>
  285. <tr>
  286. <td>Data #1</td>
  287. <td>Data #2</td>
  288. <td>Data #3</td>
  289. </tr>
  290. </tbody>
  291. <tfoot>
  292. <tr>
  293. <td>Footer #1</td>
  294. <td>Footer #2</td>
  295. <td>Footer #3</td>
  296. </tr>
  297. </tfoot>
  298. </table>
  299. `````
  300. ```html
  301. <table>
  302. <caption>...</caption>
  303. <thead>
  304. <tr>
  305. <th>...</th>
  306. </tr>
  307. </thead>
  308. <tbody>
  309. <tr>
  310. <td>...</td>
  311. </tr>
  312. </tbody>
  313. <tfoot>
  314. <tr>
  315. <td>...</td>
  316. </tr>
  317. </tfoot>
  318. </table>
  319. ```
  320. ### `<img>`
  321. More details in [Image Component](/css/image)
  322. `````html
  323. <img class="am-img-responsive" src="http://7jpqbr.com1.z0.glb.clouddn.com/bing-1.jpg" alt=""/>
  324. `````
  325. ```html
  326. <img class="am-img-responsive" src="http://7jpqbr.com1.z0.glb.clouddn.com/bing-1.jpg" alt=""/>
  327. ```
  328. ### Other Elements
  329. <table class="am-table am-table-bordered am-table-hover am-table-striped">
  330. <thead>
  331. <tr>
  332. <th>Element</th>
  333. <th>Default Style</th>
  334. </tr>
  335. </thead>
  336. <tbody>
  337. <tr>
  338. <td><code>&lt;a&gt;</code></td>
  339. <td><a href="#">This is a link</a></td>
  340. </tr>
  341. <tr>
  342. <td><code>&lt;em&gt;</code></td>
  343. <td><em>I'm in an 'em' element</em></td>
  344. </tr>
  345. <tr>
  346. <td><code>&lt;strong&gt;</code></td>
  347. <td><strong>Strong element</strong></td>
  348. </tr>
  349. <tr>
  350. <td><code>&lt;code&gt;</code></td>
  351. <td><code>Inline code</code></td>
  352. </tr>
  353. <tr>
  354. <td><code>&lt;del&gt;</code></td>
  355. <td><del>Cut me</del></td>
  356. </tr>
  357. <tr>
  358. <td><code>&lt;ins&gt;</code></td>
  359. <td><ins>I'm inserted</ins></td>
  360. </tr>
  361. <tr>
  362. <td><code>&lt;mark&gt;</code></td>
  363. <td><mark>I'm marked with mark</mark></td>
  364. </tr>
  365. <tr>
  366. <td><code>&lt;q&gt;</code></td>
  367. <td><q>I'm in a q element <q>q element in q element</q> q element</q></td>
  368. </tr>
  369. <tr>
  370. <td><code>&lt;abbr&gt;</code></td>
  371. <td>Responsive web design <abbr title="Responsive web design">RWD</abbr></td>
  372. </tr>
  373. <tr>
  374. <td><code>&lt;dfn&gt;</code></td>
  375. <td>Define something <dfn title="Enjoy your music, photos and videos, anywhere anytime">DLNA</dfn></td>
  376. </tr>
  377. <tr>
  378. <td><code>&lt;small&gt;</code></td>
  379. <td><small>I'm smaller</small></td>
  380. </tr>
  381. </tbody>
  382. </table>