If I want to use the css-grid and make one of its child fill up the remaining width when the other child is not present on the screen, how would I do something like that?
var button = document.querySelector('.click');
var buttone = document.querySelector('.clicke')
var left = document.querySelector('.left');
button.addEventListener('click', function(e) {
left.style.display = 'none';
})
buttone.addEventListener('click', function(e) {
left.style.display = 'block';
})
html,
body {
margin: 0;
}
.wrap {
display: grid;
width: 100vw;
height: 100vh;
background-color: black;
grid-template-columns: 1fr 1fr;
grid-template-areas: "left right"
}
.left {
grid-area: left;
background-color: green;
}
.right {
grid-area: right;
background-color: red
}
<div class='wrap'>
<div class='left'>
<button class='click'>HIDE ME</button>
</div>
<div class='right'>
<button class='clicke'>SHOW HIM</button>
</div>
</div>
For example, if the green's display becomes none, I would like for the red to fill up the remaining spot in the grid. I can use other displays to achieve this effect easily, but I wanted to know if there was a method to do this while using a grid display with its areas being specifically laid out.