forked from wesbos/hot-tips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
css-golden-ratio-Container-Queries.html
147 lines (133 loc) · 3.55 KB
/
css-golden-ratio-Container-Queries.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!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">
<title>CSS Golden Ratio</title>
</head>
<body>
<div class="grid">
<div class="box a"><p>CONTAINER</p></div>
<div class="box b"><p>CONTAINER</p></div>
<div class="box c"><p>CONTAINER</p></div>
<div class="box d"><p>CONTAINER</p></div>
<div class="box e"><p>CONTAINER</p></div>
<div class="box f"><p>CONTAINER</p></div>
<div class="box g"><p>CONTAINER</p></div>
</div>
<div class="grid">
<div class="box a"><p>CONTAINER</p></div>
<div class="box b"><p>CONTAINER</p></div>
<div class="box c"><p>CONTAINER</p></div>
<div class="box d"><p>CONTAINER</p></div>
<div class="box e"><p>CONTAINER</p></div>
<div class="box f"><p>CONTAINER</p></div>
<div class="box g"><p>CONTAINER</p></div>
</div>
<div class="grid" style="writing-mode: vertical-lr; aspect-ratio: 1/ 1.61803398875;">
<div class="box a"><p>CONTAINER</p></div>
<div class="box b"><p>CONTAINER</p></div>
<div class="box c"><p>CONTAINER</p></div>
<div class="box d"><p>CONTAINER</p></div>
<div class="box e"><p>CONTAINER</p></div>
<div class="box f"><p>CONTAINER</p></div>
<div class="box g"><p>CONTAINER</p></div>
</div>
<style>
.grid {
width: 100%;
aspect-ratio: 1.61803398875 / 1;
display: grid;
/* Values from https://codepen.io/Rplus/pen/JWNEOO */
grid-template-columns: 61.8% 9.02% 5.58% 23.6%;
grid-template-rows: 61.8% 9.02% 5.58% 23.6%;
grid-template-areas: "A B B B" "A E F C" "A E G C" "A D D C";
}
/*
Container CSS
*/
.box {
container: box / inline-size;
}
.box p {
font-size: 12cqmin;
}
/*
One font size for the every single box!
*/
.box:nth-child(4n) { background-position: 0 0; }
.box:nth-child(4n + 2) { background-position: 100% 0; }
.box:nth-child(4n + 3) { background-position: 100% 100%; }
.box:nth-child(4n + 4) { background-position: 0 100%; }
.box.a {
grid-area: A;
background-color: #F72585;
}
.box.b {
grid-area: B;
background-color: #B5179E;
}
.box.c {
grid-area: C;
background-color: #7209B7;
}
.box.d {
grid-area: D;
background-color: #560BAD;
}
.box.e {
grid-area: E;
background-color: #3F37C9;
}
.box.f {
grid-area: F;
background-color: #4361EE;
}
.box.g {
grid-area: G;
background-color: #fb8500;
}
/* Not important, makes look nice! */
html {
color: whitesmoke;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: 900;
}
body {
display: grid;
place-items: center;
grid-template-columns: 2fr 1fr 1fr;
min-height: 100vh;
gap: 50px;
}
@media (max-width: 1200px) {
body {
grid-template-columns: 1fr;
}
.grid:nth-child(2) {
width: 60%;
}
}
/* border box */
* {
box-sizing: border-box;
}
.box {
display: flex;
justify-content: center;
align-items: center;
border: 5px solid rgba(74, 73, 73, 0.1);
background-size:200% 200%;
background-repeat: no-repeat;
}
.box p {
mix-blend-mode: luminosity;
}
h2 {
color: black;
text-align: center;
}
</style>
</body>
</html>