简体   繁体   English

通常,以styles.css或angular-cli.json导入CSS文件更好吗?

[英]As a rule is it better to import css files in styles.css or angular-cli.json?

As a rule is it better to import css files in styles.css using @import or angular-cli.json ? 通常,使用@import或angular-cli.json在styles.css中导入css文件更好吗? One observation is that css files directly imported as url's for eg. 一种观察是,css文件直接作为URL导入,例如。 https://fonts.googleapis.com/css?family=Roboto:300,400,500,700 cannot be imported in angular-cli.json but only in styles.css. https://fonts.googleapis.com/css?family=Roboto:300,400,500,700不能在angular-cli.json中导入,而只能在styles.css中导入。

Also importing in styles.css does not require a server restart but angular-cli.json requures a server restart. 同样,在styles.css中导入不需要重启服务器,但是angular-cli.json要求重启服务器。 Which of above are recommended and why ? 建议使用以下哪项?为什么?

It really depends on what you are looking for. 这实际上取决于您要查找的内容。

you can get that CSS for fonts, add it as static CSS to your styles.css, and download the fonts and serve them yourself. 您可以获取该字体的CSS,将其作为静态CSS添加到您的styles.css中,然后下载字体并自己提供。

The other thing to consider is a CDN for those fonts, look up you'll find many CDN providers for google fonts, here is an example http://fontcdn.org/ 要考虑的另一件事是这些字体的CDN,查找您会发现许多Google字体的CDN提供程序,下面是示例http://fontcdn.org/

Additionally, please read the google font faq the have a few recommendations for performance. 此外,请阅读Google字体常见问题解答 ,并提供一些性能建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM