I am trying to display grid with columns and rows. I want to follow the method describe here
The reason i am using that method is it requires minimum css (just one line).
I have accomplished almost 98% just unable to get one thing remained is i am not able to get 1) columns aligned properly 2) vertical scroll bar for mobile.
I am new so unable to describe exact issue using words. So, I am posting image 
I have tried a lot and also studied grid property but unable to get it done. Below is my code....
var slider = document.getElementById('slider');
var toggle = document.getElementById('toggle');
toggle.addEventListener('click', function() {
var isOpen = $slider.classList.contains('slide-in');
slider.setAttribute('class', isOpen ? 'slide-out' : 'slide-in');
});
function myFunction() {
var change = document.getElementById("toggle"); // <button id="toggle">
if (change.textContent == "Close") {
change.textContent = "Before After Result";
} else {
change.textContent = "Close";
}
}
#slider {
display: grid;
grid-gap: 5px;
grid-template-columns: repeat(auto-fit, minmax(100px, 3fr));
grid-template-rows: repeat(2, 100px);
position: fixed;
bottom: 25px;
width: 100%;
background: blue;
transform: translateX(-100%);
}
#slider > div > img {
width: 100%;
height: 100%;
object-fit: cover;
}
.slide-in {
animation: slide-in 0.5s forwards;
}
.slide-out {
animation: slide-out 0.5s forwards;
}
@keyframes slide-in {
100% {
transform: translateX(0%);
}
}
@keyframes slide-out {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(-100%);
}
}
<div class="container">
<div id="slider" class="slide-in">
<div><img src="Untitled-1.png" /></div>
<div><img src="Untitled-1.png" /></div>
<div><img src="Untitled-1.png" /></div>
<div><img src="Untitled-1.png" /></div>
</div>
</div>
<button id="toggle" onclick="myFunction()" style="position:fixed;bottom:0;background-color:#f14e4e;overflow:auto;" class="button4">Close</button>