如何使mat-select始终在angular2的表单字段下始终打开? [英] How to make mat-select always open right under the form field in angular2?

查看:64
本文介绍了如何使mat-select始终在angular2的表单字段下始终打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有角材料的垫选择组件在它的表单字段下打开,但是它会打开所选选项位置的下拉列表,并且容器会根据所选选项从顶部移到一点.有没有办法在表单字段下打开下拉容器?

I need the angular material mat-select component to open right under it's form field but it opens the dropdown on selected option position and the container moves a little to top according to the selected option. Is there a way to open the drop-down container right under the form field?

推荐答案

该行为由Material Design规定.您可以使用 disableOptionCentering 选项关闭所选选项的居中功能,但这会将顶部选项放在该字段的下方而不是其下方.您可以通过指定 panelClass 选项并适当设置 display position 属性来使用CSS覆盖该属性,但是如果窗口空间不足,则无法正常使用防止面板在标准位置打开.

That behavior is prescribed by Material Design. You can turn off the centering over the selected option with the disableOptionCentering option, but this puts the top option over the field not below it. You could override that using CSS by specifying a panelClass option and set display and position properties appropriately, but this will not work properly if the window space prevents the panel from opening in the standard position.

这篇关于如何使mat-select始终在angular2的表单字段下始终打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆