I'm newbie in Angular and Angular material. I'm creating a form and want to change the background color for example for Red.
But instead of simply changing the background color, the red color get over the form.
<form class="example-form" style="background-color:red">
<mat-form-field class="example-full-width">
<mat-label>Favorite food</mat-label>
<input matInput placeholder="Ex. Pizza" value="Sushi">
</mat-form-field>
<mat-form-field class="example-full-width">
<mat-label>Leave a comment</mat-label>
<textarea matInput placeholder="Ex. It makes me feel..."></textarea>
</mat-form-field>
</form>
Here is an example on stackblitz: Example
Can someone say me, how is the correct way for setting the background color?
Thank you!
The default color of the elements is rgba(0, 0, 0, 0.04). That's black with 96% transparency. On white background it's similar to rgb(245, 245, 245). You can add the CSS rule
:host ::ng-deep .mat-form-field-flex {
background: rgb(245, 245, 245);
}
to change the background color of the divs and keep the default color on all backgrounds.
See: https://stackblitz.com/edit/angular-ka5hm7-jxen6p?file=src/app/input-overview-example.css
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With