<!doctype html>
<title>Example</title>
<style>
#grid {
display: grid;
grid-template-rows: 20vh 1fr 20vh;
grid-template-columns: 5em 5em 1fr;
grid-gap: 10px;
height: 90vh;
animation: myAnimation 1s ease 1s 5 alternate forwards;
}
#grid > div {
background-color: dodgerblue;
color: white;
font-size: 4vw;
padding: 10px;
@keyframes myAnimation {
100% {
grid-template-rows: 30vh 1fr 30vh;
</style>
<div id="grid">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
</div>