angular - Angular Material中带有菜单的完整背景图像
问题描述
此示例不起作用,如何将此图像应用于全屏背景?对于内容块background-image
作品,我不能申请background-image
导航。
.menu-spacer {
flex: 1 1 auto;
}
.bg{
width: 100%;
height: 100%;
background: url('https://images.unsplash.com/photo-1497091071254-cc9b2ba7c48a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1353&q=80') no-repeat center;
background-size: 100% 100%;
background-position: top center;
background-repeat: no-repeat;
}
<div style="height: 80vh" class="bg" >
<mat-toolbar >
<mat-toolbar-row>
<button mat-icon-button (click)="sidenav.toggle()" fxShow="true" fxHide.gt-sm>
<i class="material-icons">
pets
</i>
</button>
<span class="menu-spacer"></span>
<div fxShow="true" fxHide.lt-md >
<!-- The following menu items will be hidden on both SM and XS screen sizes -->
</div>
</mat-toolbar-row >
</mat-toolbar>
<mat-sidenav-container fxFlexFill >
<mat-sidenav #sidenav >
<mat-nav-list>
</mat-nav-list>
</mat-sidenav>
</mat-sidenav-container>
</div>
解决方案
如果我得到你想要的,你需要将样式添加到.mat-toolbar
类中以使其工作。
.mat-toolbar {
background: url('https://images.unsplash.com/photo-1497091071254-cc9b2ba7c48a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1353&q=80') no-repeat center;
background-size: cover;
color: #fff;
}
请参阅此StackBlitz 示例。
它甚至可以与多行工具栏一起使用。
推荐阅读
- java - 流程图中的扫描仪| 爪哇
- angular - 将搜索过滤器添加到 Angular-6-datatable
- mysql - 如何仅从没有架构的选定表中转储数据
- ios - 为什么 tableview 数据源不会从 Realm Collection 观察者改变?
- javascript - Chrome JS 错误:混合内容:对于机器人
- apache-spark - Spark-提交 CoarseGrainedExecutorBackend 错误
- javascript - 如何使用 DataTables 和 Excel 解决 parseXML 问题?
- javascript - Karma - Jasmine 断开连接超时
- javascript - 当鼠标离开调用元素并停留在目标元素上时保持目标元素打开
- kubernetes - k8s - 删除集群时持久存储会发生什么/?