您可以使用
position: fixed
将侧边栏固定在左侧,然后让内容部分滚动并保持侧边栏固定!
样式.scss
html,
body {
font-family: Roboto, 'Helvetica Neue', sans-serif;
margin: 0;
}
html,
body {
height: 100%;
}
组件.scss
.example-container {
border: 1px solid #555;
display: block;
height: 1000%;
width: 100%;
}
:host {
display: block;
height: 100%;
width: 100%;
}
.fixed-left {
position: fixed;
left: 0;
top: 0;
botttom: 0;
}
html
<mat-drawer-container class="example-container">
<mat-drawer mode="side" opened class="fixed-left"
>Make this sticky</mat-drawer
>
<mat-drawer-content><div>Main content</div></mat-drawer-content>
</mat-drawer-container>