css - 如何在Angular 6+中使mat-form-field-underline 0的高度
问题描述
我目前正在使用 angular 7 处理有角材料。我们如何调整 mat-form-field-underline 的高度,从而进一步在选择框周围设置边框。
<mat-form-field>
<mat-select>
<mat-option *ngFor="let type of types" [value]="type.value">{{type.viewValue}}</mat-option>
</mat-select>
</mat-form-field>
我尝试使用以下方式提供 css:
.link-1 .mat-form-field-underline{
height: 0px !important;
}
这里的link-1是父分区。但我没有发现任何区别。
谢谢你。
解决方案
试试下面的。基本上你需要使用::ng-deep
// You can use /deep/ also
::ng-deep .mat-form-field-underline {
// background: red !important;
height: 0 !important;
}
如果您对弃用警告感到困扰,您可以将 ViewEncapsulation 设置为 None ,如下所示
import {Component, ViewEncapsulation} from '@angular/core';
@Component({
selector: 'form-example',
templateUrl: 'form-example.html',
styleUrls: ['form-example.css'],
encapsulation: ViewEncapsulation.None
})
.mat-form-field-underline {
height: 0 !important;
}
推荐阅读
- typescript - 如何通过删除属性将对象从接口A转换为接口B
- reactjs - Reack.JS 使用 useState 形成多输入
- java - java - 如何在java springboot中通过电子邮件发送HSSFWorkbook xls?
- c - 为什么从 C 调用 Rust 库会导致内存泄漏?
- excel - 计算后如何让单元格继承新值?
- javascript - ExtJS 如何使绘制精灵响应?
- python - 如何在自身内部使用一个类
- android - 无法打开 Android Studio - JVM 问题
- react-native - react-native-gifted-chat 如果图像为空,如何将用户头像显示为用户的初始头像
- minio - 如何使用 MinIO Client (mc) 对 MinIO 对象进行 SQL 查询?