I need help finding a way to customize the CSS of form fields (such as input) based on the id value.
Let's take a look at an example:
HTML:
<mat-form-field class="form-field-container">
<input tabindex="0" id="{{ myVar.name }}" matInput [formControlName]="myVar.name" autocomplete="off"
[placeholder]="myVar.placeholder" />
</mat-form-field>
The current CSS I'm using:
.mat-input-element {
background: transparent !important;
color: #000000 !important;
border: none !important;
outline: none;
padding: 0px 0px 5px 0px !important;
margin: 0 !important;
width: 100% !important;
}
.input.mat-input-element {
margin-top: 1% !important;
}
My goal is to achieve the following:
- If myVar.name = val1, then set
width: 30%;
in the CSS - If myVar.name = val2, then set
width: 20%;
in the CSS
I've attempted using selectors, but it hasn't been successful:
input[id="val1"] {
width: 30%;
}
Appreciate any assistance provided. Thanks!