Typography 排版

我们对字体进行统一规范,力求在各个操作系统下都有最佳展示效果。

字体

Typography 排版 - 图1

  1. <script lang="ts" setup>
  2. import { isDark } from '~/composables/dark'
  3. </script>
  4. <template>
  5. <div v-if="!isDark" class="demo-term-box">
  6. <img src="/images/typography/term-pingfang.png" alt="" />
  7. <img src="/images/typography/term-hiragino.png" alt="" />
  8. <img src="/images/typography/term-microsoft.png" alt="" />
  9. <img src="/images/typography/term-helvetica.png" alt="" />
  10. <img src="/images/typography/term-arial.png" alt="" />
  11. </div>
  12. <div v-else class="demo-term-box">
  13. <img src="/images/typography/term-pingfang-dark.png" alt="" />
  14. <img src="/images/typography/term-hiragino-dark.png" alt="" />
  15. <img src="/images/typography/term-microsoft-dark.png" alt="" />
  16. <img src="/images/typography/term-helvetica-dark.png" alt="" />
  17. <img src="/images/typography/term-arial-dark.png" alt="" />
  18. </div>
  19. </template>
  20. <style scoped>
  21. img {
  22. width: 220px;
  23. height: 174px;
  24. margin: 0 24px 24px 0;
  25. }
  26. img:nth-of-type(3) {
  27. margin-right: 0;
  28. }
  29. </style>

字号

Typography 排版 - 图2

  1. <template>
  2. <table class="demo-typo-size">
  3. <tbody>
  4. <tr>
  5. <td>Level</td>
  6. <td>Font Size</td>
  7. <td class="color-dark-light">Demo</td>
  8. </tr>
  9. <tr
  10. v-for="(fontSize, i) in fontSizes"
  11. :key="i"
  12. :style="`font-size: var(--el-font-size-${fontSize.type})`"
  13. >
  14. <td>{{ fontSize.level }}</td>
  15. <td>
  16. {{
  17. useCssVar(`--el-font-size-${fontSize.type}`).value +
  18. ' ' +
  19. formatType(fontSize.type)
  20. }}
  21. </td>
  22. <td>Build with Element</td>
  23. </tr>
  24. </tbody>
  25. </table>
  26. </template>
  27. <script lang="ts" setup>
  28. import { useCssVar } from '@vueuse/core'
  29. const fontSizes = [
  30. {
  31. level: 'Supplementary text',
  32. type: 'extra-small',
  33. },
  34. {
  35. level: 'Body (small)',
  36. type: 'small',
  37. },
  38. {
  39. level: 'Body',
  40. type: 'base',
  41. },
  42. {
  43. level: 'Small Title',
  44. type: 'medium',
  45. },
  46. {
  47. level: 'Title',
  48. type: 'large',
  49. },
  50. {
  51. level: 'Main Title',
  52. type: 'extra-large',
  53. },
  54. ]
  55. function formatType(type: string) {
  56. return type
  57. .split('-')
  58. .map((item) => item.charAt(0).toUpperCase() + item.slice(1))
  59. .join(' ')
  60. }
  61. </script>

行高

Typography 排版 - 图3

  1. <script lang="ts" setup>
  2. import { isDark } from '~/composables/dark'
  3. </script>
  4. <template>
  5. <div>
  6. <img
  7. v-if="isDark"
  8. class="lineH-left"
  9. src="/images/typography/line-height-dark.png"
  10. />
  11. <img v-else class="lineH-left" src="/images/typography/line-height.png" />
  12. <ul class="lineH-right">
  13. <li>line-height:1 <span>No line height</span></li>
  14. <li>line-height:1.3 <span>Compact</span></li>
  15. <li>line-height:1.5 <span>Regular</span></li>
  16. <li>line-height:1.7 <span>Loose</span></li>
  17. </ul>
  18. </div>
  19. </template>

Font-family

  1. font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB',
  2. 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;

源代码

文档 Typography 排版 - 图4