【发布时间】:2019-05-10 23:28:09
【问题描述】:
我有这种使用 Angular Material Select 的 html 结构
<mat-form-field class="year-drpdwn-vacay-stock">
<mat-select placeholder="Year">
<mat-option>None</mat-option>
<mat-option *ngFor="let yr of year" [value]="yr">{{yr}}</mat-option>
</mat-select>
</mat-form-field>
我放置了一个类,因为我也在其他组件中使用了 Select。我尝试添加
::ng-deep .mat-select-panel {
margin-top: 20%;
}
在 CSS 中自定义,但问题是,包含另一个选择框的其他组件也会受到影响(继承 margin-top CSS)
目前我有这个 CSS
.year-drpdwn-vacay-stock mat-select.mat-select :host ::ng-deep .mat-select-panel {
margin-top: 20%;
}
但它仍然不起作用。
更新
目标:我希望选项面板在打开选择框时稍微向下移动,这就是为什么我希望 .mat-select-panel 的上边距为 20%
【问题讨论】:
-
你能告诉我们你真正想要做什么吗?
-
@Justcode 我希望 mat-select-panel 在打开选择框时移动一点。感谢你的提问。我会更新我的问题
标签: css angular angular-material material-design angular-material2