1
<!doctype html>
2
<title>Example</title>
3
<style>
4
#grid {
5
  display: grid;
6
  grid: auto auto auto / auto auto auto;
7
  grid-gap: 10px;
8
  animation: myAnimation 5s ease 1s 5 alternate forwards;
9
}
10
#grid > div {
11
  background-color: orchid;
12
  color: white;
13
  font-size: 4vw;
14
  padding: 10px;
15
}
16
@keyframes myAnimation {
17
  30% {
18
  grid-gap: 30px;
19
  }
20
  60% {
21
  grid-gap: 0px;
22
  }
23
}  
24
</style>
25
<div id="grid">
26
  <div>1</div>
27
  <div>2</div>
28
  <div>3</div>
29
  <div>4</div>
30
  <div>5</div>
31
  <div>6</div>
32
  <div>7</div>
33
  <div>8</div>
34
  <div>9</div>
35
</div>