-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
215 lines (196 loc) · 5.89 KB
/
index.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
<html>
<header>
<style>
body {
background-color: white;
margin: 0px;
padding: 0px;
}
/* ensure img don't break flex grid alignments */
img {
max-width: 100%;
}
/* column so each section is a row */
.main-container {
display: flex;
flex-direction: column;
height: 100%;
}
/* each section has multiple tiles, use display: flex to create a grid like layout */
.section {
display: flex;
flex: 1;
}
/* some generic styling for tiles */
.tile {
margin: 10px;
padding: 10px;
background-color: lightblue;
flex: 1;
min-height: 100px;
}
/* tiles to demonstrate align-items & justify-content flex container properties */
.tile1 {
display: flex;
align-items: flex-start;
justify-content: flex-start;
}
.tile2 {
display: flex;
align-items: center;
justify-content: center;
}
.tile3 {
display: flex;
align-items: flex-end;
justify-content: flex-end;
}
</style>
</header>
<body>
<div class="main-container">
<div class="section">
<div class="tile tile1">
<a href="layouts/layout1.html" target="_window">
Flex Layout 1 - Top Left Main
</a>
</div>
<div class="tile tile2">
<a href="layouts/layout2.html" target="_window">
Flex Layout 2 - Top Main Right
</a>
</div>
<div class="tile tile3">
<a href="layouts/layout3.html" target="_window">
Flex Layout 3 - Top Main Bottom
</a>
</div>
</div>
<div class="section">
<div class="tile">
<iframe src="layouts/layout1.html" width="100%" height="100%"></iframe>
</div>
<div class="tile">
<iframe src="layouts/layout2.html" width="100%" height="100%"></iframe>
</div>
<div class="tile">
<iframe src="layouts/layout3.html" width="100%" height="100%"></iframe>
</div>
</div>
<div class="section">
<div class="tile">
position: absolute - relative to ancestor - changes layout
<div style="position:absolute; background-color:red; top:0px; left:0px; width:200px">absolute (1) - top 0 left 0</div>
<div style="position:absolute; background-color:red; opacity: 0.3;">absolute (2)</div>
<div style="background-color:blue;">-------------------- div after 2x absolute divs</div>
</div>
<div class="tile">
position: relative - to current position - no change of layout
<div style="position:relative; background-color:green; top:50px; left:50px">relative</div>
<div style="background-color:lightcyan;">div after relative</div>
</div>
<div class="tile">
position: static - top right bottom left does not apply
<div style="position:static; background-color:yellow; top:50px; left:50px">static</div>
</div>
</div>
<div class="section">
<div class="tile">
<div>
Try:
<a href="http://sass.js.org/" target="_window">
Sass.js Playground
</a>
<pre>
<code>
@import "_variables";
@import "_demo";
.selector {
margin: $size;
background-color: $brandColor;
.nested {
margin: $size / 2;
}
&:hover {
cursor: pointer;
}
}
</code>
</pre>
<a href="https://css-tricks.com/the-sass-ampersand/" target="_window">
Sass Ampersand (&)
</a>
<pre>
<code>
// example 1 - inverting parent & child
.button {
body.page-about & {
background-color: blue;
}
}
// example 2 - replace & with compiled parent selector
.parent {
.child {
& div & & > a {
background-color: blue;
}
}
}
// example 3
.parent {
.child {
.grand-child & {
&.sibling {
background-color: blue;
}
}
}
}
</code>
</pre>
</div>
</div>
<div class="tile">
<div>
<a href="https://www.w3schools.com/css/css_combinators.asp" target="_window">
CSS Combinators
</a>
<ul>
<li>descendant selector (space)</li>
<li>child selector (>)</li>
<li>adjacent sibling selector (+)</li>
<li>general sibling selector (~)</li>
</ul>
<img src="assets/css-combinators.webp" />
</div>
</div>
<div class="tile">
<div>
<a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/" target="_window">
CSS Flex
</a>
<p>
<a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/#aa-align-items" target="_window">align-items</a> (flex-direction: row)
</p>
<img src="assets/flex-align-items.svg" />
<p>
<a href="https://www.freecodecamp.org/news/flex-basis-property-in-flexbox" target="_window">
flex-basis
</a>
- initial width/height of item depending on flex direction
</p>
<img src="assets/flex-basis.svg" />
<p>
<a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/#aa-justify-content" target="_window">justify-content</a> (flex-direction: row)
</p>
<p>
<a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/#aa-align-content" target="_window">align-content</a> (flex-direction: row)
</p>
<p>gap: row-gap, column-gap</p>
<p>flex: flex-grow, flex-shrink and flex-basis</p>
</div>
</div>
</div>
</div>
</body>
</html>