为什么当我设置深色主题时,背景本身仍保持白色?我需要自己安装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 themat-app-background
class to your wrapper element (for example thebody
). 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/