如何设置mat-select的面板组件的样式。从文档中我得到我需要提供panelClass,所以我这样做:
<mat-form-field>
<mat-select placeholder="Search for"
[(ngModel)]="searchClassVal"
panelClass="my-select-panel-class"
(change)="onSearchClassSelect($event)">
<mat-option *ngFor="let class of searchClasses" [value]="class.value">{{class.name}}</mat-option>
</mat-select>
</mat-form-field>
我在开发人员工具中检查到,这个类被附加到DOM中的面板上,并且它被附加了。因此,我将我的自定义scss类附加到此元素。现在,当我提供css时,它就不工作了。以我的scss为例,如下所示:
.my-select-panel-class {
width:20px;
max-width:20px;
background-color: red;
font-size: 10px;
}
面板的宽度始终等于选择元素的width
。有时在选项中,你有太长的字符串,我想把它做得更宽一点。有没有办法做到这一点。我的组件风格就是不能工作,甚至background-color
也不能工作。有人知道为什么这个行为这么奇怪吗?
我使用的是: Angular 4.4.5 @angular/material: 2.0.0-beta.12
https://stackoverflow.com/questions/46766597
复制相似问题