【发布时间】:2019-05-14 14:11:04
【问题描述】:
我希望 Angular Material 对话框内容中的 iframe 是:
- 最大尺寸为 560x315px
- 响应大小取决于父对话框容器。如果容器小于最大宽度
- 保持纵横比。
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