css - 删除 Material 对话框上的怪异边框

标签 css angular typescript angular6 angular-material-6

我使用 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;
}

最佳答案

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

dialog { 
  border: none !important;
}

将样式放入组件时未应用样式的原因是因为在组件范围内您无权访问 mat-dialog.您的组件将在 mat-dialog 组件内呈现,在不同的组件中。

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

关于css - 删除 Material 对话框上的怪异边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51223161/

相关文章:

jquery - LeanModal.js - 最简单的 jQuery 模态脚本故障排除

html - 停止 Bootstrap3 按钮文本以在鼠标悬停时打开下划线

javascript - 错误 : Effect dispatched an invalid action: undefined

css - 我们如何强制打印机包含 th 和 td 颜色

angular - Office.js : Increasingly poorer performance writing a large amount of rows to Excel

typescript - 如何添加使用动态组件加载器创建的组件的表单值?

javascript - Typescript - 在对象属性中引用枚举时出错

reactjs - 如何使用 typescript 扩展react-bootstrap组件?

javascript - 如何等待子组件任务完成后再继续

javascript - 更改内容可编辑的 div 中某些字符的字体大小