-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path08-css-layout.html
More file actions
415 lines (339 loc) · 14.8 KB
/
08-css-layout.html
File metadata and controls
415 lines (339 loc) · 14.8 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS layout</title>
<meta name="description" content="CSS Box Model">
<meta name="author" content="Code with me, Tom Giratikanon, Sisi Wei">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/theme/default.css">
<link rel="stylesheet" href="css/codewithme.css">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<script>
// If the query includes 'print-pdf' we'll use the PDF print sheet
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Used to fade in a background when a specific slide state is reached -->
<div class="state-background"></div>
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section class="small">
<h1 class="opening special-margin">CSS layout</h1>
<div class="small-logo-container disappear">
<img src="images/basic-logo-tan-bg.png"/>
<div class="copyright">© <span>2013</span></div>
</div>
</section>
<section>
<h2>What is layout?</h2>
<!-- <p>Arranging your content on a web page.</p> -->
<div class="stack" style="width: 700px">
<div class="fragment layer">
<img src="images/presentations/css-layout/no-layout.png" alt="">
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/comparison.png" alt="">
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/highlight.png" alt="">
</div>
</div>
<div class="notes">
<p>Many of you are interested in designing pages, or making your articles look better. Layout is a big part of that.</p>
</div>
</section>
<section>
<h2>What you can do with layout</h2>
<ul>
<!-- <li><a href="http://www.grantland.com/story/_/id/9175394/out-great-alone">Out in the Great Alone</a></li> -->
<li><a href="http://www.washingtonpost.com/sf/sports/wp/2013/02/27/cyclings-road-forward/" target='_blank'>Cycling's Road Forward</a></li>
<li><a href="http://www.nytimes.com/interactive/2013/02/15/world/europe/16meteorite_videogrid.html" target='_blank'>A Meteor From Six Vantage Points</a></li>
</ul>
</section>
<section>
<h2>Layout on the web</h2>
<div class="stack single" style="width: 700px">
<div class="fragment layer">
<img src="images/presentations/css-layout/floats/0_line.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/floats/1_cutting.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/floats/2_hey.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/floats/3_boxes.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/floats/4_floating.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/floats/5_pulling.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/floats/6_floated.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/floats/7_flowing.png" />
</div>
</div>
<img src="" alt="">
<div class="notes">
<p>Normally, elements on a page are like people standing in line at the movie theater. First come, first serve, and you're not going to just walk up next to someone -- if you get there late, you're going to the end of the line.</p>
</div>
</section>
<section class="small">
<h2>Introducing floats</h2>
<img src="images/presentations/css-layout/web-floats.png">
<div class="credit">Adapted from CSS Tricks' "<a href="http://css-tricks.com/all-about-floats/">All About Floats</a>."</div>
<div class="notes">
<p>
To borrow a metaphor from the website CSS Tricks, a float is like a pull quote or photo in a magazine layout: An element that is pulled to the left or right and lets other content flow around it.
</p>
<p>
You've noticed until now that, every HTML paragraph, header, image is laid out consecutively, one on top of another. Floats let lay out content side by side.
</p>
</div>
</section>
<section>
<h2>How floats work</h2>
<div class="stack single" style="width: 700px">
<div class="fragment layer">
<img src="images/presentations/css-layout/walkthrough/1_start.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/walkthrough/2_boxes.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/walkthrough/3_highlight.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/walkthrough/4_pull.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/walkthrough/5_flow.png" />
</div>
<div class="fragment layer">
<img src="images/presentations/css-layout/walkthrough/6_line.png" />
</div>
</div>
<img src="" alt="">
<div class="notes">
<p>Normally, elements on a page are like people standing in line at the movie theater. First come, first serve, and you're not going to just walk up next to someone -- if you get there late, you're going to the end of the line.</p>
</div>
</section>
<section class="small">
<h2>A simple float</h2>
<div class="disappear">
<div style="float:left; width: 640px; text-align:left;">index.html</div><div style="float:left;">styles.css</div>
<div style="clear:both;"></div>
<pre class="double-editor wide" style="width:620px;"><code style="width:580px;"><img src="http://i.imgur.com/i8U98Ln.jpg">
<p>
Scientists have recently identified a shocking new truth: cats are far deadlier to wildlife than anyone realized.
</p></code></pre>
<pre class="double-editor wide" style="width:220px;"><code>img {
float: left;
}</code></pre>
</div>
<div class="bottom narrow plain clearfix">
<img style="float: left; margin: 0 20px 0 0" src="http://placekitten.com/200/200?image=3" width=150 />
<p>Scientists have recently identified a shocking new truth: cats are far deadlier to wildlife than anyone realized.</p>
</div>
<div class="notes">
<p>That's all it takes. Not bad! You can also float: right.</p>
</div>
</section>
<section class="small">
<h2>A simple float right</h2>
<div class="disappear">
<div style="float:left; width: 640px; text-align:left;">index.html</div><div style="float:left;">styles.css</div>
<div style="clear:both;"></div>
<pre class="double-editor wide" style="width:620px;"><code style="width:580px;"><img src="http://i.imgur.com/i8U98Ln.jpg">
<p>
Scientists have recently identified a shocking new truth: cats are far deadlier to wildlife than anyone realized.
</p></code></pre>
<pre class="double-editor wide" style="width:220px;"><code>img {
float: right;
}</code></pre>
</div>
<div class="bottom narrow plain clearfix">
<img style="float: right; margin: 0 0 0 20px" src="http://placekitten.com/200/200?image=3" width=150 />
<p>Scientists have recently identified a shocking new truth: cats are far deadlier to wildlife than anyone realized.</p>
</div>
<div class="notes">
<p>Like so.</p>
</div>
</section>
<section class="small">
<h2>Side-by-side floats</h2>
<div class="disappear">
<div style="float:left; width: 640px; text-align:left;">index.html</div><div style="float:left;">styles.css</div>
<div style="clear:both;"></div>
<pre class="double-editor wide" style="width:620px;"><code style="width:580px;"><div class="book-one">
It is a truth universally acknowledged, that a single man in possession of a good fortune must be in want of a wife.
</div>
<div class="book-two">
Happy families are all alike; every unhappy family is unhappy in its own way.
</div></code></pre>
<pre class="double-editor wide" style="width:220px;"><code>.book-one {
float: left;
width: 340px;
}
.book-two {
float: left;
width: 340px;
}</code></pre>
</div>
<div class="bottom">
<p class="book-one">
It is a truth universally acknowledged, that a single man in possession of a good fortune must be in want of a wife.
</p>
<p class="book-two">
Happy families are all alike; every unhappy family is unhappy in its own way.
</p>
</div>
<div class="notes">
<p>To float two columns of text, or anything else, side by side, just add a float to each one, and be sure to add a width as well.</p>
</div>
</section class="small">
<section class="small">
<h2>Collapsed elements</h2>
<div class="disappear">
<div style="float:left; width: 540px; text-align:left;">index.html</div><div style="float:left;">styles.css</div>
<div style="clear:both;"></div>
<pre class="double-editor wide" style="width:530px;"><code style="width:490px;"><div class="container">
<p class="book-one">
It is a truth universally acknowledged, that a single man in possession of a good fortune must be in want of a wife.
</p>
</div><</code></pre>
<pre class="double-editor wide" style="width:320px;"><code>.book-one {
float: left;
width: 340px;
}
.container {
border: 1px solid #000;
padding: 10px;
}</code></pre>
</div>
<div class="bottom">
<div class="container">
<p class="book-one">
It is a truth universally acknowledged, that a single man in possession of a good fortune must be in want of a wife.
</p>
</div>
</div>
<!-- <div class="disappear left-column">
<div class="stacked-editor">
<p>styles.css</p>
<pre ><code>.book-one {
float: left;
width: 150px;
}
.book-two {
float: left;
width: 150px;
}</code></pre>
</div>
<div class="stacked-editor">
<p>index.html</p>
<pre><code><div class="book-one">Pride and Prejudice, By Jane Austen</div>
<div class="book-two">Pride and Prejudice and Zombies, By Seth Grahame-Smith</div></code></pre>
</div>
</div>
<div class="disappear plain right-example">
<p class="title">browser</p>
<div class="right-exampler-inner">
<div class="book-one">Pride and Prejudice, By Jane Austen</div>
<div class="book-two">Pride and Prejudice and Zombies, By Seth Grahame-Smith</div>
</div>
</div> -->
<div class="notes">
We can see here that the parent of a float is behaving strangely -- the border should go all the way around the quote, but it's collapsed. But there is a fix.
</div>
</section>
<section class="small">
<h2>Fixing the collapse</h2>
<div class="disappear">
<div style="float:left; width: 540px; text-align:left;">index.html</div><div style="float:left;">styles.css</div>
<div style="clear:both;"></div>
<pre class="double-editor wide" style="width:530px;"><code style="width:490px;"><!-- Clearfix on parent -->
<div class="container clearfix">
<p class="book-one"> <!-- Float -->
It is a truth universally acknowledged, that a single man in possession of a good fortune must be in want of a wife.
</p>
</div></code></pre>
<pre class="double-editor wide" style="width:320px;"><code>...
.clearfix:after {
content: ".";
visibility: hidden;
display: block;
height: 0;
clear: both;
}</code></pre>
</div>
<div class="bottom">
<!-- Clearfix on parent -->
<div class="container clearfix">
<p class="book-one"> <!-- Float -->
It is a truth universally acknowledged, that a single man in possession of a good fortune must be in want of a wife.
</p>
</div>
</div>
<div class="notes">
<p>There's a technique called "clearfix" that solves this problem. It's something you can google -- say, "css tricks micro clearfix", and copy the code they provide.</p>
<p>You might say that it is a truth universally acknowledged, that a parent element in possession of a floated child must be in want of a clearfix.</p>
</div>
</section>
<section class="small">
<h2>With your mentor:</h2>
<ul>
<li><strong>Do exercise #8</strong>: A parade of floats</li>
<!-- <li><strong>Do exercise #8b</strong>: Design it Twitter-style, part three</li> -->
<li>Work on your project.</li>
</ul>
</section>
</div>
<!-- The navigational controls UI -->
<aside class="controls">
<a class="left" href="#">◄</a>
<a class="right" href="#">►</a>
<a class="up" href="#">▲</a>
<a class="down" href="#">▼</a>
</aside>
<!-- Presentation progress bar -->
<div class="progress"><span></span></div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/linear(2d)
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/highlight.js', async: true, callback: function() { window.hljs.initHighlightingOnLoad(); } },
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'lib/js/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'lib/js/data-markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'socket.io/socket.io.js', async: true, condition: function() { return window.location.host === 'localhost:1947'; } },
{ src: 'plugin/speakernotes/client.js', async: true, condition: function() { return window.location.host === 'localhost:1947'; } },
]
});
</script>
</body>
</html>