我在我的应用程序中使用 Angular Material 选择,您可以在这里找到 https://material.angular.io/components/select/overview .问题是当我们将选择放在屏幕底部附近时,当它打开时,它会溢出屏幕。这是我正在经历的截图。需要什么样的 CSS 才能防止这种情况发生。
<mat-select style="margin-bottom: 0px;" placeholder="{{input1.title}}" >
<mat-option>None</mat-option>
<mat-option *ngFor="let opt_value of input1.enumNameGroups[grp_value] let i = index" value="{{input1.enumidGroups[grp_value][i]}}" >{{opt_value}}</mat-option>
</mat-optgroup>
</mat-select>
最佳答案
您可以覆盖分页器面板的默认 css 以将其放置在屏幕上的任何位置:
::ng-deep .mat-select-panel {
position: fixed;
bottom: 0;
left: 0;
height: 300px;
width: 100%;
}
根据要放置元素的位置更改类的属性。
关于css - 为什么 Angular Material 选择溢出屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49977202/