【发布时间】:2020-01-28 18:45:19
【问题描述】:
我正在尝试让我的材质对话框在右上角有一个 X 按钮,但我在定位方面遇到了问题。
组件.ts
this.d.open(loginComponent, {
width: '300px',
height: '',
panelClass: 'dialogC',
});
component.html
<mat-dialog-content>
<button mat-button class="close-icon" [mat-dialog-close]="true">
<mat-icon>close</mat-icon>
</button>
<h2 mat-dialog-title>Login</h2>
style.scss
.dialogC {
position: relative !important;
}
.close-icon {
position: absolute;
top: 0;
right: 0;
transform: translate(50%, -50%);
}
X 只是左对齐而不是右上角。有什么建议吗?
更新,这是我添加flex后遇到的问题:
【问题讨论】:
标签: html css angular typescript angular-material