How to apply common css to all components from style. Css in angular, I changed in package. Json under styles to point to styles. Css, can body suggest away other than this.
CodePudding user response:
When you add common css in src/style.css you can access in your html file. When you create angular project already your style.css mentioned in angular.json file. If there is not mention you should mention it like this.
"styles": [
"src/styles.css"
]
then you can call your css in your component html file. for example your common css is
.login-fields {
color: #8e8d8d;
}
you can call this login-fields in your html as a class.
<div >Hello</div>
CodePudding user response:
Your angular project should already contain global style.css located at src/styles.css if there isn't one you could create it. Then just make sure you also reference it in angular.json
"styles": [
"src/styles.css"
],
In style.css you could paint all div backgrounds red, for example.
An example for you: https://stackblitz.com/edit/angular-4rrj6m?file=src/styles.css
