container.children[i].style.animationIterationCount = aliveCount;
<!DOCTYPE html>
<html>
<head>
<title>生命游戏</title>
<style>
body {
background-color: #333;
font-family: Arial, sans-serif;
}
#container {
position: relative;
width: 600px;
height: 400px;
border: 1px solid black;
.cell {
position: absolute;
width: 50px;
height: 50px;
border: 1px solid gray;
font-size: 24px;
.alive {
width: 0;
height: 0;
background-color: white;
cursor: pointer;
.alive.alive-front {
animation: pulse 2s infinite;
.alive.alive-rear {
animation: pulse 1s infinite;
@keyframes pulse {
0% {
width: 100%;
height: 100%;