forked from wesbos/hot-tips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
animated-grid-container-query.html
57 lines (52 loc) · 1.22 KB
/
animated-grid-container-query.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./base.css">
<title>CSS Golden Ratio</title>
</head>
<body>
<div class="grid">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
</div>
<style>
.grid {
display: grid;
--col1: 1fr;
--col2: 1fr;
--col3: 1fr;
grid-template-columns: var(--col1) var(--col2) var(--col3);
height: 100vh;
transition: all .2s;
}
.grid:has(.item:nth-child(3n+1):hover) {
--col1: 3fr;
}
.grid:has(.item:nth-child(3n+2):hover) {
--col2: 3fr;
}
.grid:has(.item:nth-child(3n+3):hover) {
--col3: 3fr;
}
.item {
background-color: #eee;
border: 1px solid #ccc;
padding: 1rem;
font-size: 2rem;
text-align: center;
display: grid;
place-content: center;
}
</style>
</body>
</html>