简体   繁体   English

角度材料选择菜单显示不正确

[英]Angular Material Select menu not showing correctly

I am using Angular Material for my project, I am using a select option but the positioning of the drop down messes up when opening. 我正在为项目使用Angular Material,正在使用选择选项,但是打开时下拉菜单的位置会混乱。

1st: 第一: 第一期

2nd: 第二名: 第二期

The first issue shows the dropdown appearing much higher than the select element. 第一个问题显示下拉列表看起来比select元素高得多。 The second issue shows that options coming up over the select element, but this is the bottom of the page so anything after the 1st option cannot be seen/selected. 第二个问题显示选项位于select元素上方,但这是页面的底部,因此无法看到/选择第一个选项之后的所有内容。

The code I'm using is: 我使用的代码是:

<mat-form-field>
  <mat-select placeholder="Favorite food" disableOptionCentering>
    <mat-option value="Pizza">
      Pizza
    </mat-option>

    <mat-option value="Taco">
      Taco
    </mat-option>

    <mat-option value="Kebab">
      Kebab
    </mat-option>

    <mat-option value="Burgers">
      Burgers
    </mat-option>
  </mat-select>
</mat-form-field>

This is taken directly from the Angular Material site. 直接从Angular Material网站获取。 I have also tried to add "disableOptionCentering" as a parameter, to disable the centering of options, but it does not work. 我也尝试添加“ disableOptionCentering”作为参数,以禁用选项的居中,但是它不起作用。

Any help is appreciated. 任何帮助表示赞赏。

Thank you 谢谢

I'm sure you have already, but make sure you followed everything on this guide: https://material.angular.io/guide/getting-started 我确定您已经这样做了,但是请确保您已遵循本指南中的所有内容: https : //material.angular.io/guide/getting-started

Did you install @angular/animations correctly and remember to import BrowserAnimationsModule? 您是否正确安装了@ angular / animations并记得导入BrowserAnimationsModule?

import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
  ...
  imports: [BrowserAnimationsModule],
  ...
})
export class PizzaPartyAppModule { }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM