-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-grid-template-areas.html
59 lines (54 loc) · 1.62 KB
/
1-grid-template-areas.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
<!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>Grid Template Areas</title>
<style>
.container {
display: grid;
grid-template-columns: 100px 50px 75px;
grid-template-rows: 50px 100px;
/* create named sections inside grid container */
grid-template-areas:
'header header header'
/* . period denotes anything */
/* without the ., the grid is unable to render properly */
/* because of unequal number does not make a box */
'sidebar content .'
/* content can span multiple rows, similar to multiple columns*/
'sidebar content .';
/* TIP: using @mediaQueries, you can rearrange the grid areas */
/* and stack vertically as screen width narrows */
}
.item {
border: 1px solid #333;
background-color: #777;
color: yellow;
}
.item1 {
/* area names are not quoted */
grid-area: content;
}
.item2 {
grid-area: header;
}
.item6 {
grid-area: sidebar;
}
</style>
</head>
<body>
<div class="container">
<div class="item item1">1</div>
<div class="item item2">2</div>
<div class="item item3">3</div>
<div class="item item4">4</div>
<div class="item item5">5</div>
<div class="item item6">6</div>
<div class="item item7">7</div>
<div class="item item8">8</div>
</div>
</body>
</html>