Issue
I have a page with scroll that uses mat-drawer component
at the left I have a menu.
I would like that the menu content stay on screen when user scrolls the page
Here's the stackblitz example.
I have tried changing positions to sticky but not working
Solution
You can just fix the sidebar to the left using position: fixed
then let the content section scroll and leave the sidebar fixed!
styles.scss
html,
body {
font-family: Roboto, 'Helvetica Neue', sans-serif;
margin: 0;
}
html,
body {
height: 100%;
}
component.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>
Answered By - Naren Murali
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.