首页 文章

删除材质对话框上的奇怪边框

提问于
浏览
0

我使用Angular material 6对话框组件 . 它显示了一个奇怪的 border . 你能告诉我如何删除它吗?我尝试过如下 . 但它没有用 . 如果我在浏览器内部(内联)这样做,那么它的工作原理 . 任何线索?

enter image description here

dialog.component.html

<h1 mat-dialog-title>Confirm</h1>
<div mat-dialog-content>
    <p>Are you sure wanted to delete the account?</p>
</div>
<div mat-dialog-actions>
    <button mat-button cdkFocusInitial [mat-dialog-close]="false">Cancel</button>
    <button mat-button [mat-dialog-close]="true">Delete</button>
</div>

dialog.componet.css

dialog.ng-star-inserted {
    border: none !important;
}

1 回答

  • 2

    最简单的方法是为 styles.css 文件中的对话框声明样式 . 像这样:

    dialog { 
      border: none !important;
    }
    

    将样式放入组件时未应用样式的原因是因为在组件范围内您无权访问mat对话框 . 您的组件将在mat-dialog组件内,在另一个组件中呈现 .

    styles.css 文件中定义的样式将在您的应用程序中全局应用 .

相关问题