-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.css
125 lines (113 loc) · 2.49 KB
/
grid.css
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
/*HTML
<div class="container">
<header>HEADER</header>
<aside>MENU</aside>
<main>CONTENT</main>
<footer>FOOTER</footer>
</div>
*/
.container {
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-template-rows: 50px 350px 50px;
}
header {
grid-column: span 12;
}
aside {
grid-column: span 2;
}
main {
grid-column: span 10;
}
footer {
grid-column: span 12;
}
/* adaptability of the template for smartphones and tablets */
@media screen and (max-width: 768px) {
aside {
grid-column: span 6;
}
main {
grid-column: span 6;
}
}
@media screen and (max-width: 480px) {
aside {
grid-column: span 12;
}
main {
grid-column: span 12;
}
}
/* Properties that specify the size and number of columns or rows of the grid layout, respectively. */
.container {
display: grid;
/* 3 columns will be created */
grid-template-columns: 40px auto 40%;
/* 3 rows will be created */
grid-template-rows: 250px 5vw 15rem;
}
/* You can explicitly name gridlines using square brackets: */
.container {
display: grid;
grid-template-columns: [start-line] 140px [line2] 250px [line3] 40px [end-line];
grid-template-rows: [row1-start] 25rem [row1-end] 10vh [last-row];
}
/* 3 columns of 250 pixels will be created: */
.container {
display: grid;
grid-template-columns: repeat(3, 250px);
}
/* free space will be divided between 2 columns */
.container {
display: grid;
grid-template-columns: 1fr 200px 1fr;
}
/* grid template for arranging items inside a grid container */
.container {
display: grid;
grid-template-columns: 200px 1fr 1fr 1fr;
grid-template-rows: repeat(4, 150px);
grid-template-areas:
"header header header header"
"menu content content content"
"menu content . content"
"footer footer footer footer";
}
.item1 {
grid-area: header;
background-color: purple;
}
.item2 {
grid-area: menu;
background-color: yellow;
}
.item3 {
grid-area: content;
background-color: pink;
}
.item4 {
grid-area: footer;
background-color: gray;
}
// Grid item properties
.container {
display: grid;
grid-template-columns: [one] 1fr [two] 1fr [three] 1fr [four] 1fr [five] 1fr [six];
grid-template-rows: [row1-start] 1fr [row1-end] 1fr 1fr;
}
.item1 {
grid-column-start: 2;
grid-column-end: five;
grid-row-start: row1-start;
grid-row-end: 3;
}
.item2 {
grid-column: 1 / 3; /* or: 1 / span 2; */
grid-row: 1 / 2; /* or: 1 / span 1; */
}
/* row-start / column-start / row-end / column-end */
.item3 {
grid-area: 4 / 2 / 5 / 4;
}