javascript - 如何在 Angular 材质组件上设置样式?
问题描述
我目前正在为我的项目使用 Angular 8。我遇到了一个问题,我需要为 Angular Material 组件设置样式,例如 mat-form-field。
这就是我们在模板中使用它的方式
<mat-form-field>
<input matInput placeholder="Input">
</mat-form-field>
在网站上它实际上是这样呈现的
<mat-form-field _ngcontent-tin-c20="" class="mat-form-field ng-tns-c21-3 mat-primary mat-form-field-type-mat-input mat-form-field-appearance-legacy mat-form-field-can-float mat-form-field-has-label mat-form-field-hide-placeholder">
<div class="mat-form-field-wrapper">
<div class="mat-form-field-flex">
<!---->
<!---->
<div class="mat-form-field-infix">
<input _ngcontent-tin-c20="" class="mat-input-element mat-form-field-autofill-control cdk-text-field-autofill-monitored" matinput="" placeholder="Input" id="mat-input-0" aria-invalid="false" aria-required="false">
<span class="mat-form-field-label-wrapper">
<!---->
<label class="mat-form-field-label ng-tns-c21-3 mat-empty mat-form-field-empty ng-star-inserted" id="mat-form-field-label-1" for="mat-input-0" aria-owns="mat-input-0">
<!---->
<!---->
<span class="ng-tns-c21-3 ng-star-inserted">Input</span>
<!---->
<!---->
</label>
</span>
</div>
<!---->
</div>
<!---->
<div class="mat-form-field-underline ng-tns-c21-3 ng-star-inserted">
<span class="mat-form-field-ripple"></span>
</div>
<div class="mat-form-field-subscript-wrapper">
<!---->
<!---->
<div class="mat-form-field-hint-wrapper ng-tns-c21-3 ng-trigger ng-trigger-transitionMessages ng-star-inserted" style="opacity: 1; transform: translateY(0%);">
<!---->
<div class="mat-form-field-hint-spacer"></div>
</div>
</div>
</div>
</mat-form-field>
例如,我现在如何更改类的样式mat-form-field-infix
?
解决方案
推荐阅读
- java - WebService Spring 不会为服务和消费者初始化 bean
- python - 我想转置具有字符串的数据框
- java - WindowCloseOnTouchOutside 时执行函数
- java - 导航抽屉位于其他小部件下
- c# - 在 C# 中使用 sql 语句更改 Oracle 数据库的用户密码
- linux - 管理区出现 gitlab 500 错误
- angularjs - 如何将本地化设置为剑道日期选择器?
- adobe-analytics - 如何提取链接类型并将其放入 evar 或 prop 中?
- c# - 如何使用本身具有自定义序列化的 ISerializable 字段在对象中实现 GetObjectData?
- android-studio - 错误:任务“:app:transformClassesWithDexForDebug”执行失败。以非零退出值 3 结束