Whenever I toggle the menu on the left to slide away, I want the body element to stretch to full width, how can I achieve this? Is using translate option not good for this? I want to use translate because the animation effect. The body width is 100% but it wont stretch fully
const nav = document.querySelector('.nav')
function toggleNav() {
nav.classList.toggle("translate")
}
.container {
display: flex;
}
.nav {
width: 150px;
background: red;
height: 100vh;
}
.body {
width: 100%;
background: blue;
}
.translate {
transform: translateX(-100%);
transition: 0.5s;
}
<button onClick="toggleNav()">
Toggle
</button>
<div class="container">
<div class="nav">
nav
</div>
<div class="body">
test
</div>
</div>