简体   繁体   English

Angular - 如何使 mat-dialog 内的 mat-stepper 内的元素调整到对话框的高度?

[英]Angular - How to make elements inside mat-stepper inside mat-dialog adjust to the height of the dialog?

I have a mat-dialog which contains a mat-stepper.我有一个 mat-dialog,其中包含一个 mat-stepper。 Inside this stepper, I have a step which contains a form.在这个步进器中,我有一个包含表单的步骤。 In this form I have multiple elements (list, mat-card and table) which I want to always fill the height of the dialog.在这种形式中,我有多个元素(列表、垫卡和表格),我希望它们始终填充对话框的高度。 Basically, I want the height of the table and also the height of the list on the left side of the table to adjust to the dialog height.基本上,我希望表格的高度以及表格左侧的列表高度调整为对话框高度。 The mat-card, which is shown when selecting an item in the list, should always be at the bottom left of the dialog and the list above it should either show all elements (if possible) or display a scroll bar if there is not enough space left to show all elements.选择列表中的项目时显示的垫卡应始终位于对话框的左下角,其上方的列表应显示所有元素(如果可能)或在元素不足时显示滚动条留出空间来显示所有元素。 The table should also either show all elements if there is enough space or display a scroll bar if there isn't enough space.如果空间足够,该表还应显示所有元素,如果空间不足,则应显示滚动条。 I do not want any of the elements in this dialog to cause an overflow which would require me to scroll in the actual dialog.我不希望此对话框中的任何元素导致溢出,这需要我在实际对话框中滚动。

A colleague attempted to solve this by using max-height: calc(90vh - <x>px) before but this really does not work very well at all.一位同事试图通过使用max-height: calc(90vh - <x>px)来解决这个问题,但这实际上根本不能很好地工作。 How can I do this properly?我怎样才能正确地做到这一点?

Here is a stackblitz which shows the problem: Stackblitz这是一个显示问题的stackblitz: Stackblitz

Hopefully, my question is clear.希望我的问题很清楚。 If not, please let me know and I will try my best to explain it in more detail.如果没有,请告诉我,我会尽力更详细地解释它。

Your problem is quite simple, the content of the dialog does not fit the height of your dialog.你的问题很简单,对话框的内容不适合你对话框的高度。

Every child of the dialog mat-dialog-content , mat-stepper etc, should be maximizing their height (either with height:100% or flex:1 in a flex container).对话框mat-dialog-contentmat-stepper等的每个子项都应该最大化它们的高度(在 flex 容器中使用height:100%flex:1 )。

Here is a quick example of this . 这是一个简单的例子

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

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