angular-cli how to add global styles?

前端 未结 13 1634
南笙
南笙 2020-12-16 09:18

I created a global style sheet using sass and put it in the public/style/styles.scss. I only specify a background color.

In the index, I added a link to

13条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 09:56

    There is also a solution to add external CSS, which is, Put all your CSS in assets/css folder like this:

    assets/css/style1.css
    assets/css/style2.css
    assets/css/style3.css
    

    AFter adding all external CSS, you have to import their reference in global style.css (i.e src/style.css) like this:

    @import 'assets/css/style1.css';
    @import 'assets/css/style2.css';
    @import 'assets/css/style3.css';
    

    Also don't forget to include global CSS in angular-cli.json like this:

      "styles": [
        "styles.css",
      ],
    

提交回复
热议问题