角材料中的模态布局响应

时间:2020-05-22 16:11:55

标签: css angular angular-material angular8 angular-flex-layout

我对在Angular Material中使用模态的响应能力有疑问。我如何使其在小屏幕上看起来不错。不必是网格

请参阅此stackblitz链接

Click Here

  openDialog() {
    const dialogRef = this.dialog.open(ModalComponent, {
      width: "650px",
      height: "380px"
    });
  }

3 个答案:

答案 0 :(得分:3)

Demo您可以在style.css中使用媒体查询

 @media only screen and (max-width: 700px) {
  .modal .mat-grid-tile {
     width:100% !important;
     position:relative!important;  
     left:0 !important; 
  }
  .modal .mat-form-field {
    width: 100%
  }
  .modal .mat-radio-button {
    padding: 10px;
  }
  .modal .mat-raised-button.mat-warn {
       margin:5px
   }
}

答案 1 :(得分:1)

如果要使用自适应布局,请不要使用mat-grid-list

答案 2 :(得分:0)

如果这是您想要的,请尝试:

openDialog() {
    const dialogRef = this.dialog.open(ModalComponent, {
        width: "100vw",
        height: "100vh",
        maxWidth: "650px",
        maxHeight: "900px"
    });

对于小型设备,您将获得“无页面”对话框。 对于较大的设备,尺寸限制为给定值。