Skip to content

Commit a3177bd

Browse files
committed
Added a grid-template shorthand example.
1 parent 1bf4202 commit a3177bd

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

grid-template-shorthand.html

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
6+
7+
.grid {
8+
display: grid;
9+
grid-template: 25px 260px 702px 538px /
10+
"top-panel top-panel top-panel top-panel" 32px
11+
"top-subpanel top-subpanel top-subpanel top-subpanel" 25px
12+
"left-panel widget-1 widget-2 widget-4" 229px
13+
"left-panel widget-1 widget-2 widget-5" 264px
14+
"left-panel widget-1 widget-3 widget-6" 260px;
15+
}
16+
17+
.sizedToGridArea {
18+
font: 10px/1 Ahem;
19+
/* Make us fit our grid area. */
20+
width: 100%;
21+
height: 100%;
22+
}
23+
24+
#topPanel {
25+
grid-area: top-panel;
26+
background-color: blue;
27+
}
28+
29+
#topSubpanel {
30+
grid-area: top-subpanel;
31+
background-color: lime;
32+
}
33+
34+
#leftPanel {
35+
grid-area: left-panel;
36+
background-color: purple;
37+
}
38+
39+
#widget1 {
40+
grid-area: widget-1;
41+
background-color: orange;
42+
}
43+
44+
#widget2 {
45+
grid-area: widget-2;
46+
background-color: pink;
47+
}
48+
49+
#widget3 {
50+
grid-area: widget-3;
51+
background-color: navy;
52+
}
53+
54+
#widget4 {
55+
grid-area: widget-4;
56+
background-color: magenta;
57+
}
58+
59+
#widget5 {
60+
grid-area: widget-5;
61+
background-color: red;
62+
}
63+
64+
#widget6 {
65+
grid-area: widget-6;
66+
background-color: black;
67+
}
68+
69+
</style>
70+
</head>
71+
<body>
72+
73+
<div class="grid">
74+
<div id="topPanel" class="sizedToGridArea"></div>
75+
<div id="topSubpanel" class="sizedToGridArea"></div>
76+
<div id="leftPanel" class="sizedToGridArea"></div>
77+
<div id="widget1" class="sizedToGridArea"></div>
78+
<div id="widget2" class="sizedToGridArea"></div>
79+
<div id="widget3" class="sizedToGridArea"></div>
80+
<div id="widget4" class="sizedToGridArea"></div>
81+
<div id="widget5" class="sizedToGridArea"></div>
82+
<div id="widget6" class="sizedToGridArea"></div>
83+
</div>
84+
85+
86+
</body>
87+
</html>

grid-template-shorthand.png

18.7 KB
Loading

index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ <h4 class="list-group-item-heading">z-index</h4>
144144
</p>
145145
<p>Example with several overlaping grid items where painting order is defined by the implicit DOM order and different z-index values.</p>
146146
</li>
147+
<li class="list-group-item">
148+
<h4 class="list-group-item-heading">Explicit Grid Shorthand: grid-template</h4>
149+
<p>
150+
<a href="grid-template-shorthand.html" class="label label-primary">example</a>
151+
<a href="https://github.com/Igalia/css-grid-layout/blob/master/grid-template-shorthand.html" class="label label-success">html</a>
152+
<a href="https://github.com/Igalia/css-grid-layout/blob/master/grid-template-shorthand.png" class="label label-info">screenshot</a>
153+
<a href="http://www.w3.org/TR/css-grid/#propdef-grid-template" class="label label-warning">spec</a>
154+
</p>
155+
<p>Example usage of the 'Explicit Grid' shorthand for setting grid-template-columns, grid-template-rows, and grid-template-areas in a single declaration.</p>
156+
</li>
147157
<li class="list-group-item">
148158
<h4 class="list-group-item-heading">DOM order</h4>
149159
<p>

0 commit comments

Comments
 (0)