How can I make the main contents move correctly here. Looks like I need some dynamic calculation of margin left or what would be the best solution here?
Initially it looks OK:
But when the menu expands:
Or when the page gets resized:
How can I make the main contents move correctly here. Looks like I need some dynamic calculation of margin left or what would be the best solution here?
Initially it looks OK:
But when the menu expands:
Or when the page gets resized:
I don't know what is the best practice, but this is how I solved similar problem.
Suppose your content looks like this.
<div class="main">
<Menu class="menu" />
<Content class="content" />
</div>
And style:
.main {
display: flex;
}
.menu {
width: 10vw;
}
.content {
width: 90vw;
}
.menu__open {
width: 25vw;
}
.content__on-menu-open {
width: 75vw;
}
The last two classes are set when menu is opened.
PS: Styling for mobile will require additional classes.
The problem was that I didn't use the content in the right place.
Based on the answer here: React Router V4 Implement NavLink inside a ListItem using Material UI
And also by using this
https://material-ui.com/components/drawers/#responsive-drawer
I was able to fix the problem. Basically I was not outputting the content in the right place.