Wang's blog Wang's blog
首页
  • 前端文章

    • HTML教程
    • CSS
    • JavaScript
  • 前端框架

    • Vue
    • React
    • VuePress
    • Electron
  • 后端技术

    • Npm
    • Node
    • TypeScript
  • 编程规范

    • 规范
  • 我的笔记
  • Git
  • GitHub
  • VSCode
  • Mac工具
  • 数据库
  • Google
  • 服务器
  • Python爬虫
  • 前端教程
更多
收藏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Wang Mings

跟随大神,成为大神!
首页
  • 前端文章

    • HTML教程
    • CSS
    • JavaScript
  • 前端框架

    • Vue
    • React
    • VuePress
    • Electron
  • 后端技术

    • Npm
    • Node
    • TypeScript
  • 编程规范

    • 规范
  • 我的笔记
  • Git
  • GitHub
  • VSCode
  • Mac工具
  • 数据库
  • Google
  • 服务器
  • Python爬虫
  • 前端教程
更多
收藏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Python爬虫

  • 前端教程

    • 团队规范

      • 前端团队规范总结
      • AI前端CSS规范
      • AI前端Git规范
      • AI前端JS规范
      • AI前端Vue规范
      • AI前端工程工具链
      • AI JavaScript 风格指南
      • 推荐-200错误统一处理
      • 推荐-优雅引用字体
        • [#](#编程式字体方法的好处) 编程式字体方法的好处
        • [#](#bad) bad
        • [#](#good) good
        • [#](#最佳字体顺序参考) 最佳字体顺序参考
          • [#](#pc端) PC端
          • [#](#移动端) 移动端
      • 推荐-Vue实例选项顺序
      • 组件设计风格
      • 推荐-Vue项目目录结构
      • 推荐-Vue-Router写法
    • Project

    • JS

    • NodeJS

    • Vue

    • React

    • 效率工具

    • 读书笔记

  • 教程
  • 前端教程
  • 团队规范
wangmings
2022-07-19
目录

推荐-优雅引用字体

# # 推荐-优雅引用字体

# # 编程式字体方法的好处

  1. 学习视觉同学对于具体字体的考量,也许还能发现视觉同学的bug
  2. 全局控制,避免样式散乱
  3. 书写字体样式成为一门艺术

# # bad

    .form-title {
        font: 'PingFang-SC-medium';
        font-size: 18px;
        font-color: #22222;
    }
    
    .form-text {
        font: 'PingFang-SC-regular';
        font-size: 14px;
        font-color: #333333;
    }
    
1
2
3
4
5
6
7
8
9
10
11
12

# # good

variables.scss文件

    $font-normal-color = #222222; // 字体颜色
    $font-light-color = #333333;
    
    @mixin font-class($fontFamily, $fontSize, $fontColor) {
        font-family: $fontFamily;
        font-size: $fontSize;
        color: $fontColor;
    }
    
    @mixin font-large($size: 14px, $color: $font-normal-color) {
        @include font-class($font-family-medium, $size, $color);
    }
    
    @mixin font-normal($size: 14px, $color: $font-light-color) {
        @include font-class($font-family-regular, $size, $color);
    }
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

应用:

    .form-title {
        @include font-large(18px, #22222);
    }
    
    .form-text {
        @include font-large(14px, #333333);
    }
    
1
2
3
4
5
6
7
8

font-large/font-normal等公用mixins建议放在统一的variables.scss文件中,再通过sass-resource自动引入到所有组件中

# # 最佳字体顺序参考

# # PC端

    $font-family-medium = 'PingFang-SC-medium', Helveti   ca, Tahoma, Arial, 'Microsoft YaHei', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif;
    $font-family-regular = 'PingFang-SC-regular', Helvetica, Tahoma, Arial, 'Microsoft YaHei', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif;
    
1
2
3

# # 移动端

    $font-family-ultralight = 'PingFangSC-Ultralight', 'Source Han Sans CN', "Helvetica Neue";
    $font-family-regular = 'PingFangSC-Regular', 'Source Han Sans CN', "Helvetica Neue";
    $font-family-medium = 'PingFangSC-Medium', 'Source Han Sans CN Medium', "Helvetica Neue";
    $font-family-thin = 'PingFangSC-Thin', 'Source Han Sans CN Thin', "Helvetica Neue";
    $font-family-light = 'PingFangSC-Light', 'Source Han Sans CN Light', "Helvetica Neue";
    $font-family-semibold = 'PingFangSC-Semibold', 'Source Han Sans CN Light', "Helvetica Neue";
    
1
2
3
4
5
6
7
编辑 (opens new window)
推荐-200错误统一处理
推荐-Vue实例选项顺序

← 推荐-200错误统一处理 推荐-Vue实例选项顺序→

最近更新
01
theme-vdoing-blog博客静态编译问题
09-16
02
搜索引擎
07-19
03
友情链接
07-19
更多文章>
Theme by Vdoing | Copyright © 2019-2022 Evan Xu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式