'Styles. Css in angular
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.
Solution 1:[1]
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 class="login-fields">Hello</div>
Solution 2:[2]
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%2Fstyles.css
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rifkhan Mohamed |
| Solution 2 | Joosep Parts |
