Angular Material 深色主题

标签 angular angular-material

为什么当我设置深色主题时,背景本身仍保持白色?我需要自己安装css黑色背景吗?或者可以以某种方式解决这个问题吗?

"styles": [
  "node_modules/@angular/material/prebuilt-themes/purple-green.css",
  "src/styles.scss"
],

最佳答案

这是因为,如果您不使用 sidenav 容器,则需要将 mat-app-background 类添加到文档的 body 元素中,如guide for theming :

Finally, if your app's content is not placed inside of a mat-sidenav-container element, you need to add the mat-app-background class to your wrapper element (for example the body). This ensures that the proper theme background is applied to your page. - Theming your Angular Material app > Using a prebuilt theme

例如:

<body class="mat-app-background">
  <app-root>Loading...</app-root>
</body>
<!-- ... -->

关于Angular Material 深色主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58316365/

相关文章:

html - 如何使用 ngClass 在 Angular 中创建幻灯片?

html - Chrome 80 中的网格模板列计算不一致

angular - oidc-client 与 IdentityServer3 - Angular2 SPA,如何刷新数据访问 token

angular - 单元测试主题 : Cannot read property 'unsubscribe' of undefined

angular - 如何在 Angular2 的某些 div 中只读所有输入?

css - Angular:如何使用查询参数过滤数据表

javascript - Angular Material - 不工作/渲染没有特定类

angular - 如何捕捉 Material Datepicker 月份分页事件?

css - md-datepicker 没有正确呈现日历

html - 如何在 Angular 2 中获取 contenteditable 'div' 的插入符号位置?