When the first element gets deleted, I want to make the other elements to slide into their new places instead of going instantly there. Using the code below, all of the other boxes move instantly to their new positions when you delete the first one. Eventually, there will be many rows of boxes.
var pile = document.getElementById("pile");
function removeFirst(){
pile.removeChild(event.target);
}
.box{
border: 1px solid black;
padding: 20px;
}
#pile{
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
<div id="pile">
<div class="box" onclick="removeFirst()">I'm the first box</div>
<div class="box">I'm the second box</div>
<div class="box">I'm the third box</div>
<div class="box">I'm the fourth box</div>
</div>