angular-cli如何添加全局样式? [英] angular-cli how to add global styles?
问题描述
我使用sass创建了一个全局样式表,并将其放在public/style/styles.scss
中.我只指定背景色.
I created a global style sheet using sass and put it in the public/style/styles.scss
. I only specify a background color.
在索引中,我添加了一个链接:<link rel="stylesheet" href="style/styles.css">
In the index, I added a link to it: <link rel="stylesheet" href="style/styles.css">
背景颜色在body标签上不起作用.检查主体标签后,我可以看到应用了背景色但被scaffolding.less:31
The background color does not work on the body tag. Upon inspecting the body tag I can see that the background-color was applied but overruled by scaffolding.less:31
我做错了什么?
预先感谢
推荐答案
从CLI的beta.14版本开始(使用Angular 2.0 final),可以在angular-cli.json
内部的样式"下链接全局样式表.钥匙.这是对相对于src/
目录的文件的引用,默认情况下为style.css
.
As of the beta.14 release of the CLI (which uses Angular 2.0 final), a global stylesheet can be linked inside angular-cli.json
under the "styles" key. This is a reference to a file relative to the src/
directory, which is style.css
by default.
利用此方法,您可以:
- 将全局样式复制到
src/styles.css
- 使用CSS导入将外部规则导入
styles.css
- 通过
angular-cli.json
中的
apps[0].styles
属性添加更多全局样式
- Copy the global styles into
src/styles.css
- Use CSS imports to import external rules into
styles.css
- Add more global styles via the
apps[0].styles
property inangular-cli.json
另请参见angular-cli
的全局样式. Wiki.
See also Global Styles in angular-cli
's wiki.
这篇关于angular-cli如何添加全局样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!