【问题标题】:Responsive Iframe within Angular Material dialog contentAngular Material 对话框内容中的响应式 iframe
【发布时间】:2019-05-14 14:11:04
【问题描述】:

我希望 Angular Material 对话框内容中的 iframe 是:

  1. 最大尺寸为 560x315px
  2. 响应大小取决于父对话框容器。如果容器小于最大宽度
  3. 保持纵横比。

SourceComponent.ts

openIFrameDialog(): void {
  this.dialog.open(IFrameDialogComponent);
}

IFrameDialogComponent.html:

<div mat-dialog-title class="close">
  <button mat-icon-button (click)="onClose()" tabindex="-1">
    <mat-icon>close</mat-icon>
  </button>
</div>
<mat-dialog-content>
    <iframe width="560" height="315" src="[yt_video_url]" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</mat-dialog-content>

我也在 IFrameDialogComponent.scss 中添加了这个:

mat-dialog-content iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

但不走运,它在整个屏幕上展开,而不是在父容器上

对如何实现上述要求有什么建议吗?

我真的很感激。

【问题讨论】:

    标签: css angular sass angular-material


    【解决方案1】:

    如何在你的 css(IFrameDialogComponent.scss) 中使用最大宽度,如下所示: max-width: 100%; max-height: 100%;

    【讨论】:

    • 我还删除了 iframe 部分中的固定值
    猜你喜欢
    • 1970-01-01
    • 2021-06-11
    • 1970-01-01
    • 2017-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    • 2019-01-01
    相关资源
    最近更新 更多