forked from material-components/material-components-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
layout-grid.html
520 lines (450 loc) · 21.4 KB
/
layout-grid.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
<!DOCTYPE html>
<!--
Copyright 2016 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License
-->
<html>
<head>
<meta charset="utf-8">
<title>Layout Grid - Material Components</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png">
<script src="/assets/layout-grid.css.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<style>
.demo-grid {
background-color: #DDDDDD;
margin-bottom: 32px;
}
.demo-cell {
box-sizing: border-box;
background-color: #666666;
height: 200px;
padding: 8px;
color: white;
font-size: 1.5em;
}
.demo-parent-cell {
position: relative;
background-color: #aaaaaa;
}
.demo-parent-cell>span{
position: absolute;
top: 8px;
left: 8px;
font-size: 1.5em;
color: white;
}
.demo-child-cell {
position: relative;
}
.demo-child-cell>span{
position: absolute;
bottom: 8px;
right: 8px;
color: #ddd;
}
.demo-grid.max-width {
max-width: 1280px;
}
.demo-grid-legend {
margin: 16px 0 8px 0;
}
.demo-ruler {
position: fixed;
display: flex;
align-items: center;
justify-content: center;
bottom: 0;
left: 0;
height: 20px;
width: 100%;
margin: 0;
background: black;
color: white;
}
.demo-controls {
display: none;
margin-bottom: 8px;
}
.demo-warning::after {
content: "This browser does not support custom properties, so margins and gutters cannot be changed at runtime.";
}
@supports (--foo: green) {
.demo-controls {
display: block;
}
.demo-warning::after {
content: "";
}
}
.examples {
margin: 24px;
}
.hero .demo-grid {
min-width: 360px;
}
.hero .demo-cell {
height: 60px;
}
</style>
</head>
<body>
<header class="mdc-toolbar mdc-toolbar--fixed">
<div class="mdc-toolbar__row">
<section class="mdc-toolbar__section mdc-toolbar__section--align-start">
<span class="catalog-back">
<a href="/" class="mdc-toolbar__icon--menu"><i class="material-icons"></i></a>
</span>
<span class="mdc-toolbar__title catalog-title">Layout Grid</span>
</section>
</div>
</header>
<main class="mdc-typography">
<div class="mdc-toolbar-fixed-adjust"></div>
<section class="hero">
<div class="demo-grid mdc-layout-grid">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
</div>
</div>
</section>
<section class="examples">
<h2 class="demo-grid-legend">Layout grid (in fluid container)</h2>
<section id="layout-grid-in-fluid-container">
<div class="mdc-layout-grid">
<div class="mdc-layout-grid__inner">
<div class="mdc-layout-grid__cell">
<div class="demo-controls">
Desktop Margin:
<select class="desktop-margin">
<option value="8px">8px</option>
<option value="16px">16px</option>
<option value="24px" selected>24px</option>
<option value="40px">40px</option>
</select>
<br>
Desktop Gutter:
<select class="desktop-gutter">
<option value="8px">8px</option>
<option value="16px">16px</option>
<option value="24px" selected>24px</option>
<option value="40px">40px</option>
</select>
</div>
</div>
<div class="mdc-layout-grid__cell">
<div class="demo-controls">
Tablet Margin:
<select class="tablet-margin">
<option value="8px">8px</option>
<option value="16px" selected>16px</option>
<option value="24px">24px</option>
<option value="40px">40px</option>
</select>
<br>
Tablet Gutter:
<select class="tablet-gutter">
<option value="8px">8px</option>
<option value="16px" selected>16px</option>
<option value="24px">24px</option>
<option value="40px">40px</option>
</select>
</div>
</div>
<div class="mdc-layout-grid__cell">
<div class="demo-controls">
Phone Margin:
<select class="phone-margin">
<option value="8px">8px</option>
<option value="16px" selected>16px</option>
<option value="24px">24px</option>
<option value="40px">40px</option>
</select>
<br>
Phone Gutter:
<select class="phone-gutter">
<option value="8px">8px</option>
<option value="16px" selected>16px</option>
<option value="24px">24px</option>
<option value="40px">40px</option>
</select>
</div>
</div>
</div>
</div>
<div class="demo-warning"></div>
<div class="demo-grid-legend">Grid of default wide (4 columns) items</div>
<div class="demo-grid mdc-layout-grid">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell">4</div>
<div class="demo-cell mdc-layout-grid__cell">4</div>
<div class="demo-cell mdc-layout-grid__cell">4</div>
</div>
</div>
<div class="demo-grid-legend">Grid of 1 column wide items</div>
<div class="demo-grid mdc-layout-grid">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
</div>
</div>
<div class="demo-grid-legend">Grid of differently sized items</div>
<div class="demo-grid mdc-layout-grid">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-6">6</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">4</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-2">2</div>
</div>
</div>
<div class="demo-grid-legend">Grid of items with tweaks at different screen sizes</div>
<div class="demo-grid mdc-layout-grid">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-6 mdc-layout-grid__cell--span-8-tablet">6 (8 tablet)</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4 mdc-layout-grid__cell--span-6-tablet">4 (6 tablet)</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-2 mdc-layout-grid__cell--span-4-phone">2 (4 phone)</div>
</div>
</div>
<div class="demo-grid-legend">Grid nested within parent grid cell</div>
<div class="demo-grid mdc-layout-grid">
<div class="mdc-layout-grid__inner">
<div class="demo-parent-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">
<div class="mdc-layout-grid__inner">
<div class="demo-child-cell demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">
<span>Child 4</span>
</div>
<div class="demo-child-cell demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">
<span>Child 4</span>
</div>
<div class="demo-child-cell demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">
<span>Child 4</span>
</div>
</div>
<span>Parent 4</span>
</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">4</div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">4</div>
</div>
</div>
<h3 class="demo-grid-legend">Grid with max width</h3>
<div class="demo-grid-legend">Grid with max width (1280px) and center alignment by default</div>
<div class="demo-grid mdc-layout-grid max-width">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
</div>
</div>
<div class="demo-grid-legend">Grid with max width (1280px) and left alignment</div>
<div class="demo-grid mdc-layout-grid max-width mdc-layout-grid--align-left">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
</div>
</div>
</section>
<h2 class="demo-grid-legend">Fixed column width layout grid</h2>
<section id="fixed-column-width-layout-grid">
<div class="mdc-layout-grid">
<div class="mdc-layout-grid__inner">
<div class="mdc-layout-grid__cell">
<div class="demo-controls">
Desktop Margin:
<select class="desktop-margin">
<option value="8px">8px</option>
<option value="16px">16px</option>
<option value="24px" selected>24px</option>
<option value="40px">40px</option>
</select>
<br>
Desktop Gutter:
<select class="desktop-gutter">
<option value="8px">8px</option>
<option value="16px">16px</option>
<option value="24px" selected>24px</option>
<option value="40px">40px</option>
</select>
<br>
Desktop Column Width:
<select class="desktop-column-width">
<option value="72px" selected>72px</option>
<option value="84px">84px</option>
</select>
</div>
</div>
<div class="mdc-layout-grid__cell">
<div class="demo-controls">
Tablet Margin:
<select class="tablet-margin">
<option value="8px">8px</option>
<option value="16px" selected>16px</option>
<option value="24px">24px</option>
<option value="40px">40px</option>
</select>
<br>
Tablet Gutter:
<select class="tablet-gutter">
<option value="8px">8px</option>
<option value="16px" selected>16px</option>
<option value="24px">24px</option>
<option value="40px">40px</option>
</select>
<br>
Tablet Column Width:
<select class="tablet-column-width">
<option value="72px" selected>72px</option>
<option value="84px">84px</option>
</select>
</div>
</div>
<div class="mdc-layout-grid__cell">
<div class="demo-controls">
Phone Margin:
<select class="phone-margin">
<option value="8px">8px</option>
<option value="16px" selected>16px</option>
<option value="24px">24px</option>
<option value="40px">40px</option>
</select>
<br>
Phone Gutter:
<select class="phone-gutter">
<option value="8px">8px</option>
<option value="16px" selected>16px</option>
<option value="24px">24px</option>
<option value="40px">40px</option>
</select>
<br>
Phone Column Width:
<select class="phone-column-width">
<option value="72px" >72px</option>
<option value="84px">84px</option>
</select>
</div>
</div>
</div>
</div>
<div class="demo-grid-legend">Fixed column width layout grid and center alignment by default</div>
<div class="demo-grid mdc-layout-grid mdc-layout-grid--fixed-column-width">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
</div>
</div>
<div class="demo-grid-legend">Fixed column width layout grid and right alignment</div>
<div class="demo-grid mdc-layout-grid mdc-layout-grid--fixed-column-width mdc-layout-grid--align-right">
<div class="mdc-layout-grid__inner">
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
<div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
</div>
</div>
</section>
<div class="demo-ruler"><div id="current"></div></div>
</section>
</main>
<script>
(function(global) {
'use strict';
var fluidContainerSection = document.getElementById('layout-grid-in-fluid-container');
var fixedWidthSection = document.getElementById('fixed-column-width-layout-grid');
var marginSelectDesktopFluid = fluidContainerSection.querySelector('.desktop-margin');
marginSelectDesktopFluid.addEventListener('change', function() {
fluidContainerSection.style.setProperty('--mdc-layout-grid-margin-desktop', marginSelectDesktopFluid.value);
});
var gutterSelectDesktopFluid = fluidContainerSection.querySelector('.desktop-gutter');
gutterSelectDesktopFluid.addEventListener('change', function() {
fluidContainerSection.style.setProperty('--mdc-layout-grid-gutter-desktop', gutterSelectDesktopFluid.value);
});
var marginSelectTabletFluid = fluidContainerSection.querySelector('.tablet-margin');
marginSelectTabletFluid.addEventListener('change', function() {
fluidContainerSection.style.setProperty('--mdc-layout-grid-margin-tablet', marginSelectTabletFluid.value);
});
var gutterSelectTabletFluid = fluidContainerSection.querySelector('.tablet-gutter');
gutterSelectTabletFluid.addEventListener('change', function() {
fluidContainerSection.style.setProperty('--mdc-layout-grid-gutter-tablet', gutterSelectTabletFluid.value);
});
var marginSelectPhoneFluid = fluidContainerSection.querySelector('.phone-margin');
marginSelectPhoneFluid.addEventListener('change', function() {
fluidContainerSection.style.setProperty('--mdc-layout-grid-margin-phone', marginSelectPhoneFluid.value);
});
var gutterSelectPhoneFluid = fluidContainerSection.querySelector('.phone-gutter');
gutterSelectPhoneFluid.addEventListener('change', function() {
fluidContainerSection.style.setProperty('--mdc-layout-grid-gutter-phone', gutterSelectPhoneFluid.value);
});
var marginSelectDesktopFixed = fixedWidthSection.querySelector('.desktop-margin');
marginSelectDesktopFixed.addEventListener('change', function() {
fixedWidthSection.style.setProperty('--mdc-layout-grid-margin-desktop', marginSelectDesktopFixed.value);
});
var gutterSelectDesktopFixed = fixedWidthSection.querySelector('.desktop-gutter');
gutterSelectDesktopFixed.addEventListener('change', function() {
fixedWidthSection.style.setProperty('--mdc-layout-grid-gutter-desktop', gutterSelectDesktopFixed.value);
});
var columnWidthSelectDesktopFixed = document.querySelector('.desktop-column-width');
columnWidthSelectDesktopFixed.addEventListener('change', function() {
document.documentElement.style.setProperty('--mdc-layout-grid-column-width-desktop', columnWidthSelectDesktopFixed.value);
});
var marginSelectTabletFixed = fixedWidthSection.querySelector('.tablet-margin');
marginSelectTabletFixed.addEventListener('change', function() {
fixedWidthSection.style.setProperty('--mdc-layout-grid-margin-tablet', marginSelectTabletFixed.value);
});
var gutterSelectTabletFixed = fixedWidthSection.querySelector('.tablet-gutter');
gutterSelectTabletFixed.addEventListener('change', function() {
fixedWidthSection.style.setProperty('--mdc-layout-grid-gutter-tablet', gutterSelectTabletFixed.value);
});
var columnWidthSelectTabletFixed = document.querySelector('.tablet-column-width');
columnWidthSelectTabletFixed.addEventListener('change', function() {
document.documentElement.style.setProperty('--mdc-layout-grid-column-width-tablet', columnWidthSelectTabletFixed.value);
});
var marginSelectPhoneFixed = fixedWidthSection.querySelector('.phone-margin');
marginSelectPhoneFixed.addEventListener('change', function() {
fixedWidthSection.style.setProperty('--mdc-layout-grid-margin-phone', marginSelectPhoneFixed.value);
});
var gutterSelectPhoneFixed = fixedWidthSection.querySelector('.phone-gutter');
gutterSelectPhoneFixed.addEventListener('change', function() {
fixedWidthSection.style.setProperty('--mdc-layout-grid-gutter-phone', gutterSelectPhoneFixed.value);
});
var columnWidthSelectPhoneFixed = document.querySelector('.phone-column-width');
columnWidthSelectPhoneFixed.addEventListener('change', function() {
document.documentElement.style.setProperty('--mdc-layout-grid-column-width-phone', columnWidthSelectPhoneFixed.value);
});
var current = document.querySelector('#current');
var update = function() {
var size = '(phone)';
if (window.innerWidth >= 840) {
size = '(desktop)';
} else if (window.innerWidth >= 480) {
size = '(tablet)';
}
current.textContent = window.innerWidth + 'px ' + size;
};
window.addEventListener('resize', update);
update();
})(this);
</script>
</body>
</html>