问题描述
我需要角材料 mat-select 组件在其表单字段的正下方打开,但它会打开所选选项位置的下拉列表,并且容器根据所选选项移动到顶部.有没有办法直接在表单域下打开下拉容器?
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 的表单字段下打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!