我們如何使用 ng deep css 類僅特定于例如 1 個復選框而不是我組件中的所有復選框
例如,我只想將它與我的一個復選框一起使用,而不是我的組件中的所有復選框。我們怎么做?謝謝。
我只想將它應用于特定的復選框。因為在我的組件中有 5 個不同的復選框,但我只想修改 1 個復選框,所以 4 個不應該受到影響。
因此,例如下面有 2 個復選框,CSS 應該只影響第一個復選框,而不包括第二個復選框
#復選框代碼
<mat-checkbox
*ngIf="currentSelectedTenants(subtenant) else currentSubtenants"
color="accent"
[(ngModel)]="dealDispositionFormFields.currentSubtenants"
[checked]="currentSelectedTenants(subtenant)"
(change)="changeCurrentSubtenants($event,subtenant)"
style="margin-left:10px;">
<mat-label class="alter-text-color" style="font-size: 12px;">{{subtenant.subtenantName}}</mat-label>
</mat-checkbox>
<mat-checkbox
*ngIf="currentSelectedTenants(subtenant) else currentSubtenants"
color="accent"
[(ngModel)]="dealDispositionFormFields.notCurrentSubtenant"
[checked]="currentSelectedTenants(subtenant)"
(change)="changeCurrentSubtenants($event,subtenant)"
style="margin-left:10px;">
<mat-label class="alter-text-color" style="font-size: 12px;">{{subtenant.subtenantName}}</mat-label>
</mat-checkbox>
#css
::ng-deep .mat-checkbox-checkmark-path {
stroke:rgba(0, 125, 255, 1) !important;
}
uj5u.com熱心網友回復:
您可以mat-checkbox在 a中添加div并為其分配一個class:
<div class="new-class">
<mat-checkbox>
</mat-checkbox>
</div>
你的 css 將如下所示:
::ng-deep .new-class .mat-checkbox-checkmark-path {
stroke:rgba(0, 125, 255, 1) !important;
}
PS:您可以new-class根據您的要求命名
uj5u.com熱心網友回復:
在要自定義的 mat-checkbox 中使用 css 類:
<mat-checkbox class="custom-mat-checkbox">
...
</mat-checkbox>
然后通過 CSS 自定義它。
::ng-deep mat-checkbox.custom-mat-checkbox {
// custom css goes here
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/339585.html
上一篇:小專案的側邊欄結構
