-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSS-grid-auto-fit-minmax.html
49 lines (49 loc) · 1.11 KB
/
CSS-grid-auto-fit-minmax.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Grid Auto fit & Minmax</title>
<style>
.container > div {
display: flex;
justify-content: center;
align-items: center;
font-size: 2em;
color: #ffeead;
}
.container > div:nth-child(even) {
color: floralwhite;
background: forestgreen;
}
.container > div:nth-child(odd) {
color: floralwhite;
background: tomato;
}
/* Grid */
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(100px,1fr));
grid-template-rows: repeat(2, 100px);
grid-auto-rows:100px ;
grid-gap: 5px;
}
</style>
</head>
<body>
<div class="container">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
</div>
</body>
</html>