-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathalignment-demo.html
122 lines (109 loc) · 3.33 KB
/
alignment-demo.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
<!DOCTYPE html>
<html>
<head>
<link href="css/grid.css" rel="stylesheet">
<style>
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 120%;
margin: 0;
padding: 0;
}
code {
font-size: 110%;
font-weight: bold;
}
select {
font-size: 110%;
}
.grid {
margin: 50px;
float: left;
grid-template-columns: 200px 200px 200px;
grid-template-rows: 200px 200px;
}
#table {
position: absolute;
top: 50px;
left: 50px;
border-collapse: collapse;
width: 600px;
height: 400px;
}
#table tr {
height: 200px;
}
#table td {
border: 2px dashed grey;
width: 300px;
}
#properties {
padding-left: 25px;
}
.grid div {
padding: 10px;
font-weight: bold;
}
.item3 {
grid-row: span 2;
}
.item4 {
grid-column: span 2;
}
</style>
<script>
function updateJustifyItems() {
var grid = document.getElementById("grid");
var justifyItems = document.getElementById("justify-items");
grid.style.webkitJustifyItems = justifyItems.value;
grid.style.justifyItems = justifyItems.value;
}
function updateAlignItems() {
var grid = document.getElementById("grid");
var alignItems = document.getElementById("align-items");
grid.style.webkitAlignItems = alignItems.value;
grid.style.alignItems = alignItems.value;
}
</script>
</head>
<body>
<div id="grid" class="grid">
<div class="item1">Item 1</div>
<div class="item2">Item 2<br>with two lines</div>
<div class="item3">Item 3<br>(spanning 2 rows)</div>
<div class="item4">Item 4<br>(spanning 2 columns)</div>
</div>
<div style="clear: both;"></div>
<div id="properties">
<h2>CSS Grid Layout: <a href="https://drafts.csswg.org/css-grid/#alignment">Alignment</a></h2>
<p>Property <a href="http://www.w3.org/TR/css3-align/#propdef-justify-items"><code>justify-items</code></a> is
<select id="justify-items" onchange="updateJustifyItems();">
<option value="stretch" selected>stretch</option>
<option value="start">start</option>
<option value="center">center</option>
<option value="end">end</option>
</select>
</p>
<p>Property <a href="http://www.w3.org/TR/css3-align/#propdef-align-items"><code>align-items</code></a> is
<select id="align-items" onchange="updateAlignItems();">
<option value="stretch" selected>stretch</option>
<option value="start">start</option>
<option value="center">center</option>
<option value="end">end</option>
</select>
</p>
</div>
<table id="table">
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>