0

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:

enter image description here

But when the menu expands:

enter image description here

Or when the page gets resized:

enter image description here

1

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.