Here's a mesmerizing life simulation animation using only HTML and CSS:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Life Simulation</title>
<style>
:root {
--cell-size: 12px;
--grid-size: 30;
--animation-speed: 20s;
}
body {
margin: 0;
padding: 0;
height: 100vh;
background: #000;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
font-family: 'Arial', sans-serif;
}
.simulation-container {
position: relative;
width: calc(var(--cell-size) * var(--grid-size));
height: calc(var(--cell-size) * var(--grid-size));
background: rgba(0, 0, 0, 0.9);
border-radius: 8px;
box-shadow: 0 0 30px rgba(0, 150, 100, 0.3);
overflow: hidden;
}
.title {
position: absolute;
top: -40px;
left: 0;
width: 100%;
text-align: center;
color: rgba(0, 255, 150, 0.8);
font-size: 18px;
letter-spacing: 2px;
text-transform: uppercase;
}
.grid {
display: grid;
grid-template-columns: repeat(var(--grid-size), var(--cell-size));
grid-template-rows: repeat(var(--grid-size), var(--cell-size));
width: 100%;
height: 100%;
}
.cell {
width: var(--cell-size);
height: var(--cell-size);
background: rgba(0, 0, 0, 0.8);
transition: background 0.3s;
position: relative;
overflow: hidden;
}
/* Create a pseudo-random pattern using nth-child selectors and animations */
.cell:nth-child(7n+1):nth-child(5n) { animation: cell-life-1 var(--animation-speed) infinite; }
.cell:nth-child(13n+3):nth-child(7n) { animation: cell-life-2 var(--animation-speed) infinite; }
.cell:nth-child(19n+7):nth-child(3n) { animation: cell-life-3 var(--animation-speed) infinite; }
.cell:nth-child(23n+11):nth-child(9n) { animation: cell-life-4 var(--animation-speed) infinite; }
.cell:nth-child(17n+5):nth-child(11n) { animation: cell-life-5 var(--animation-speed) infinite; }
.cell:nth-child(29n+13):nth-child(13n) { animation: cell-life-6 var(--animation-speed) infinite; }
.cell:nth-child(31n+17):nth-child(17n) { animation: cell-life-7 var(--animation-speed) infinite; }
.cell:nth-child(37n+19):nth-child(19n) { animation: cell-life-8 var(--animation-speed) infinite; }
.cell:nth-child(41n+23):nth-child(23n) { animation: cell-life-9 var(--animation-speed) infinite; }
.cell:nth-child(43n+29):nth-child(29n) { animation: cell-life-10 var(--animation-speed) infinite; }
/* Animations for cell life cycles */
@keyframes cell-life-1 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
10%, 30% { background: rgba(0, 255, 150, 0.8); }
40%, 60% { background: rgba(0, 200, 120, 0.6); }
70%, 90% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-2 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
20%, 40% { background: rgba(0, 255, 150, 0.8); }
50%, 70% { background: rgba(0, 200, 120, 0.6); }
80%, 95% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-3 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
5%, 25% { background: rgba(0, 255, 150, 0.8); }
35%, 55% { background: rgba(0, 200, 120, 0.6); }
65%, 85% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-4 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
15%, 35% { background: rgba(0, 255, 150, 0.8); }
45%, 65% { background: rgba(0, 200, 120, 0.6); }
75%, 95% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-5 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
25%, 45% { background: rgba(0, 255, 150, 0.8); }
55%, 75% { background: rgba(0, 200, 120, 0.6); }
85%, 95% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-6 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
30%, 50% { background: rgba(0, 255, 150, 0.8); }
60%, 80% { background: rgba(0, 200, 120, 0.6); }
85%, 95% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-7 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
5%, 15% { background: rgba(0, 255, 150, 0.8); }
25%, 45% { background: rgba(0, 200, 120, 0.6); }
55%, 75% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-8 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
35%, 55% { background: rgba(0, 255, 150, 0.8); }
65%, 85% { background: rgba(0, 200, 120, 0.6); }
90%, 95% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-9 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
40%, 60% { background: rgba(0, 255, 150, 0.8); }
70%, 90% { background: rgba(0, 200, 120, 0.6); }
95%, 98% { background: rgba(0, 150, 80, 0.4); }
}
@keyframes cell-life-10 {
0%, 100% { background: rgba(0, 0, 0, 0.8); }
45%, 65% { background: rgba(0, 255, 150, 0.8); }
75%, 95% { background: rgba(0, 200, 120, 0.6); }
96%, 99% { background: rgba(0, 150, 80, 0.4); }
}
/* Pattern propagation effect */
.cell:hover {
background: rgba(0, 255, 150, 1) !important;
}
.cell:hover ~ .cell:nth-child(n+1):nth-child(-n+5) {
background: rgba(0, 255, 150, 0.8) !important;
transition-delay: 0.1s;
}
.cell:hover ~ .cell:nth-child(n+6):nth-child(-n+15) {
background: rgba(0, 200, 120, 0.6) !important;
transition-delay: 0.2s;
}
/* Environment effects */
.environment {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
.nutrient {
position: absolute;
width: 2px;
height: 2px;
background: rgba(0, 255, 150, 0.5);
border-radius: 50%;
animation: float-nutrient 15s linear infinite;
}
@keyframes float-nutrient {
0% {
transform: translate(calc(var(--x) * 1%), calc(var(--y) * 1%)) scale(0);
opacity: 0;
}
50% {
transform: translate(calc(var(--x) * 1% + 20px), calc(var(--y) * 1% - 20px)) scale(1);
opacity: 0.8;
}
100% {
transform: translate(calc(var(--x) * 1% + 40px), calc(var(--y) * 1% - 40px)) scale(0);
opacity: 0;
}
}
/* Stats display */
.stats {
position: absolute;
bottom: -40px;
left: 0;
width: 100%;
display: flex;
justify-content: space-around;
color: rgba(0, 255, 150, 0.8);
font-size: 12px;
}
.stat {
display: flex;
flex-direction: column;
align-items: center;
}
.stat-value {
width: 40px;
height: 4px;
background: rgba(0, 100, 50, 0.5);
border-radius: 2px;
margin-top: 5px;
position: relative;
overflow: hidden;
}
.stat-value::before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
background: rgba(0, 255, 150, 0.8);
animation: stat-animation 10s ease-in-out infinite;
}
.stat:nth-child(1) .stat-value::before {
animation-duration: 17s;
width: 75%;
}
.stat:nth-child(2) .stat-value::before {
animation-duration: 13s;
width: 45%;
}
.stat:nth-child(3) .stat-value::before {
animation-duration: 19s;
width: 60%;
}
@keyframes stat-animation {
0%, 100% { transform: translateX(0); }
50% { transform: translateX(10px); }
}
/* Ambient background effect */
.ambient {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.8) 100%);
opacity: 0.7;
pointer-events: none;
animation: ambient-pulse 15s ease-in-out infinite;
}
@keyframes ambient-pulse {
0%, 100% { opacity: 0.7; }
50% { opacity: 0.5; }
}
</style>
</head>
<body>
<div class="simulation-container">
<div class="title">Life Simulation</div>
<div class="grid">
<!-- Generate 900 cells (30x30 grid) -->
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div>
<div class="cell"></div><div class="cell"></div><div class="cell"></div><div class="cell"></div><div