【问题标题】:As a rule is it better to import css files in styles.css or angular-cli.json?通常,在styles.css 或angular-cli.json 中导入css 文件更好吗?
【发布时间】:2017-08-29 13:43:22
【问题描述】:

作为一项规则,使用 @import 或 angular-cli.json 在 styles.css 中导入 css 文件更好吗?一项观察是 css 文件直接作为 url 导入,例如。https://fonts.googleapis.com/css?family=Roboto:300,400,500,700 不能在 angular-cli.json 中导入,只能在 styles.css 中导入。

同样导入 styles.css 不需要重启服务器,但 angular-cli.json 需要重启服务器。 推荐以上哪一项,为什么?

【问题讨论】:

    标签: css angular angular-cli


    【解决方案1】:

    这真的取决于你在寻找什么。

    您可以获取字体的 CSS,将其作为静态 CSS 添加到您的 styles.css,然后下载字体并自行提供。

    要考虑的另一件事是这些字体的 CDN,查找您会发现许多 Google 字体的 CDN 提供商,这里有一个示例 http://fontcdn.org/

    另外,请阅读google font faq 有一些关于性能的建议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-05
      • 2018-02-05
      • 1970-01-01
      • 1970-01-01
      • 2012-02-09
      • 2017-04-25
      • 1970-01-01
      相关资源
      最近更新 更多