angular-cli how to add global styles?

前端 未结 13 1582
南笙
南笙 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 10:11

    Sep 2019:

    Most other posts are old.

    File: \angular.json
    Key : projects > myProjectNameHere > architect > build > styles

    "styles": [
        "src/styles.css",
        "node_modules/font-awesome/css/font-awesome.css",
        {
            "input": "./node_modules/bootstrap/dist/css/bootstrap.css"
        }
    ],
    

    File: src/styles.css

    /* You can add global styles to this file, and also import other style files */
    /* That is, have put css that is common for all pages in this file.  */
    
    body {
      font-family: "Ubuntu", sans-serif;
    }
    

    With above two things, the css is applying fine to all pages.

    So, nothing new to be done if you have Angular 8 or above.
    If you have an issue, then you only need to clear cache (or, do Ctrl + Shift + R )

提交回复
热议问题