最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Transparent background in angular material dialog - Stack Overflow

programmeradmin5浏览0评论

I am trying to change the color of the angular material dialog using css var (), but instead of the color I need, the background bees transparent.

Css style:

.custom-dialog >  mat-dialog-container {
  background: var(--background);
}

Open dialog function:

openDialogForCreateDirectory(): void {
    this.dialog.open(CreateDirectoryComponent, {
      width: '400px',
      panelClass: 'custom-dialog'
    });
  }

I am trying to change the color of the angular material dialog using css var (), but instead of the color I need, the background bees transparent.

Css style:

.custom-dialog >  mat-dialog-container {
  background: var(--background);
}

Open dialog function:

openDialogForCreateDirectory(): void {
    this.dialog.open(CreateDirectoryComponent, {
      width: '400px',
      panelClass: 'custom-dialog'
    });
  }
Share Improve this question asked Apr 4, 2020 at 16:11 Nikita KachanNikita Kachan 731 gold badge1 silver badge3 bronze badges 1
  • Does this answer your question? How to close a mat dialog without a backdrop on clicking outside? – Dane Brouwer Commented Mar 17, 2021 at 12:40
Add a ment  | 

2 Answers 2

Reset to default 5

You need to use ::ng-deep to force the style down to angular material ponents:

::ng-deep .custom-dialog > mat-dialog-container {
  background-color: var(--background);
}

See working example: https://stackblitz./angular/ebnbevodyrv

To change anything in angular-material library UI, need to add css in styles.scss i.e. root level.

See here

发布评论

评论列表(0)

  1. 暂无评论