Skip to content

Commit 49affa4

Browse files
Simplified floats section, added example screenshots, remove redundant example files.
1 parent c0feae3 commit 49affa4

12 files changed

Lines changed: 86 additions & 232 deletions
282 KB
Loading
201 KB
Loading
51.6 KB
Loading

index.html

Lines changed: 50 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,16 @@ <h2>Setting Up Our Work Flow</h2>
170170
1. The folder will appear in the side bar. Double click on **index.html** in the sidebar to open it. The basic HTML tags for all web pages have been included in this file.
171171
1. Right click or two finger tap in Sublime and select **Open in Browser**. This will open the HTML file in your *default* browser.
172172

173-
What do you see? Your page should look like [exercise 1](project/examples/exercise1.html).
173+
You should see this:
174+
175+
![project start example](framework/img/workshop/project-start.jpg)
174176

175177
</section>
176178

177179
<section class="slide">
178180
<h2 id="making-changes">Making changes</h2>
179181

180-
<p>Let's make a change. Replace the “your name here” content, save the file, then refresh your browser.</p>
181-
182-
<p>This will be your work flow for the day.</p>
182+
<p>Let's make a change. Replace the “your name here” content, save the file, then refresh your browser. This will be your work flow for the day.</p>
183183

184184
<ol>
185185
<li>update the code</li>
@@ -310,7 +310,7 @@ <h2>Exercise #1 - Updating your home page (5 mins)</h2>
310310

311311
<p>Don’t forget to save and refresh your browser after each change!</p>
312312

313-
<p>Your page should now look similar to <a href="project/examples/exercise1-updated.html">exercise1-updated.html</a></p>
313+
<p>Your page should now look similar to <a href="project/examples/exercise1.html">exercise1.html</a></p>
314314

315315
<div class="presenter-notes">
316316
<p>Use the exercise time to follow along with the current exercise. Since the exercises switch between code-alongs and independent exercises throughout the day, it will be easier to demonstrate the code-alongs if your version is at the same state as the learners.</p>
@@ -888,15 +888,13 @@ <h2>CSS Font Styles</h2>
888888
<section class="slide">
889889
<h2>Lunchtime! (Optional Exercise)</h2>
890890

891-
<p>Picking fonts is hard. For this project, we'll be using web fonts from Google fonts. Prepare for the post-lunch exercise by picking 2-3 fonts from <a href="https://www.google.com/fonts">Google Fonts</a> for the body text, header and highlighted text. Here’s a <a href="/project/final/">the final project</a> for reference.</p>
891+
<p>Picking fonts is hard. For this project, we'll be using web fonts from Google fonts. Prepare for the post-lunch exercise by picking 2-3 fonts from <a href="https://www.google.com/fonts">Google Fonts</a> for the body text, header and cursive text. Here’s a <a href="/project/final/about.html">the final project</a> for reference.</p>
892892

893-
894-
895893
<p><strong>Need some help choosing?</strong><p>
896894
<p>Here’s some inspiration: <a href="http://hellohappy.org/beautiful-web-type/">http://hellohappy.org/beautiful-web-type/</a></p>
897895
<p>Or try Source Sans Pro, Quicksand, Merriweather or Codystar.</p>
898896

899-
<p>If you can't decide which fonts to use, just use the example project fonts: Open Sans (light), Nixie One and Pacifico. The font file links will be provided in the post-lunch exercise.</p>
897+
<p>If you can't decide which fonts to use, just use the example project fonts: Open Sans (light), Nixie One and Pacifico. The font file links are provided in the post-lunch exercise.</p>
900898

901899
<div class="presenter-notes">
902900
<p>Aim to get to lunch around 12:30pm. A 45 min lunch is recommended since the afternoon covers a lot & more advanced concepts. Let the learners know this is optional but most people tend to enjoy continuing on a bit of exercises over the break. This will help speed up the next exercise and give them time to personalize their font choices without cutting into class time. If not, they can just use the suggested fonts.</p>
@@ -1125,7 +1123,7 @@ <h2>Box Model Review</h2>
11251123
<section class="slide" data-markdown>
11261124
##Class Exercise - headings and spacing
11271125

1128-
Now that **styles.css** is linked to all three pages, these next updates will apply to all of them.
1126+
Now that **styles.css** is linked to all three pages, these next updates will apply to all of the pages.
11291127

11301128
Add padding to the `header` and `section` so there's an equal amount of space around the content blocks.
11311129

@@ -1234,9 +1232,9 @@ <h3>Inline Elements</h3>
12341232
</section>
12351233

12361234
<section class="slide">
1237-
<h2>Class Exercise - Horizontal navigation</h2>
1235+
<h2>Class Exercise #5 - Horizontal navigation</h2>
12381236

1239-
<p>In this step, we're focusing on changing the default list styles to a horizontal layout. It will look like this sample below (also found in your examples folder, <a href="project/examples/exercise5-home.html">exercise 5</a>).</p>
1237+
<p>In this step, we're focusing on changing the default list styles to a horizontal layout. It will look like this sample below (also found in your examples folder, <a href="project/examples/exercise5-about.html">exercise 5</a>).</p>
12401238
<img src="framework/img/workshop/exercise5-nav.png" alt="">
12411239
<p>First, remove the default list spacing and bullets.</p>
12421240
<pre><code>nav ul {
@@ -1323,19 +1321,23 @@ <h2>Class Exercise - Horizontal navigation</h2>
13231321
&lt;h1&gt;&lt;span class=&quot;highlight&quot;&gt;Jane&lt;/span&gt;Smith&lt;/h1&gt;
13241322
```
13251323

1326-
Now it looks like this! Add this anywhere you want some highlighted text!
1324+
Now it looks like this!
13271325

13281326
![](framework/img/workshop/highlighted-text.png)
1327+
1328+
Add this anywhere you want some highlighted text! Your name is also in the footer. That would be another good place to add this style.
13291329
</section>
13301330

13311331
<section class="slide" data-markdown>
13321332
##CSS Float Property
13331333

1334-
Remember, block-style HTML elements like `&lt;p>`, `&lt;div>` and `&lt;section>` automatically start on a new line and stack on top of each other. To get two block elements to align side-by-side, the `float` property can also be used to float elements left or right.
1334+
Remember, block-style HTML elements like `&lt;p>`, `&lt;div>` and `&lt;section>` automatically start on a new line and stack on top of each other. That's why our content is currently just stacking on top of each other.
13351335

1336-
**However**, we have to break the natural stacking flow when an element is floated. This will cause any element *after* the floated element to try to move up beside it or just not display properly because we've disrupted the natural stacking flow. The parent container will also collapse.
1336+
![](framework/img/workshop/about-not-floated.png)
13371337

1338-
**Also**, if no width is set, the element will float but the width will automatically be the width of its content.
1338+
To get two block elements to align side-by-side, we've used `display: inline-block` but the `float` property is often used for creating page layouts.
1339+
1340+
**However**, we have to break the natural stacking flow when an element is floated. This will cause any element *after* the floated element to try to move up beside it or just not display properly because we've disrupted the natural stacking flow. The parent container will also collapse.
13391341
</section>
13401342

13411343
<section class="slide centered">
@@ -1345,97 +1347,70 @@ <h2>Huh?</h2>
13451347
<p class="delayed">Not to worry, we can fix it.</p>
13461348
</section>
13471349

1350+
<section class="slide" data-markdown>
1351+
##Floating content
1352+
1353+
For the next exercise, we'll use `float` to align the profile image and the text beside each other to make it look like this:
1354+
1355+
![](framework/img/workshop/about-floated.png)
1356+
</section>
13481357
<section class="slide">
1349-
<h2>Float, Clear And Clearfix</h2>
1358+
<h2>Float & Clear</h2>
13501359

13511360
<p>First we have to break it, then put it back together. We need to “reset” the float to get the rest of the page to go back to normal. There are a couple ways to do it.</p>
13521361

1353-
<p>One of the most confusing CSS concepts is when to use the different techniques, <code>clear: both</code> or the <code>.clearfix</code> class.</p>
1362+
<p>One of the most confusing CSS concepts is when to use the different techniques.</p>
13541363

1355-
<p>Let’s look at an example: <a href="http://jsfiddle.net/unjcxses/">http://jsfiddle.net/unjcxses/</a></p>
1364+
<p>Let’s look at an example: <a href="http://jsfiddle.net/e1nd3q89/">http://jsfiddle.net/e1nd3q89/</a></p>
13561365

1357-
<p>Rule of thumb: if there’s is an element that <em>follows</em> the floated element, apply <code>clear: both</code> to that element. This will clear the float. If all the elements need to be floated, apply the <code>clearfix</code> to the parent element to force clear the children.</p>
1366+
<p><strong>Rule of thumb:</strong><br>
1367+
If there is an element that <em>follows</em> the floated elements, apply <code>clear: both</code> to that element. If all the elements need to be floated, apply the <code>overflow:hidden</code> to the <em>parent element</em> to force clear the children.</p>
13581368

1359-
<p>Want to know more about the clearfix trick and clearing floats? Here you go: <br>
1360-
<a href="http://css-tricks.com/snippets/css/clear-fix/">http://css-tricks.com/snippets/css/clear-fix/</a> <br>
1361-
<a href="http://www.sitepoint.com/clearing-floats-overview-different-clearfix-methods/">http://www.sitepoint.com/clearing-floats-overview-different-clearfix-methods/</a></p>
1369+
<p>Want to know more about clearing floats? Here you go: <br>
1370+
<a href="http://www.sitepoint.com/clearing-floats-overview-different-clearfix-methods/">http://www.sitepoint.com/clearing-floats-overview-different-clearfix-methods/</a><br>
1371+
<a href="http://css-tricks.com/snippets/css/clear-fix/">http://css-tricks.com/snippets/css/clear-fix/</a></p>
13621372

13631373
<div class="presenter-notes">
13641374
<p>Explain that you can fork or update the jsfiddle to create your own copy and it won't "mess up" the example. It will create a new URL and no account is required.</p>
13651375
</div>
13661376
</section>
13671377

13681378
<section class="slide" data-markdown>
1369-
##Update the CSS file
1379+
##Class Exercise #6 - Update About page with Floats
13701380

1371-
Before moving onto the next exercise, let's add the [clearfix class](http://nicolasgallagher.com/micro-clearfix-hack/) to our CSS file, after the box model fix.
1372-
1373-
```
1374-
/* apply a natural box layout model to all elements, but allowing components to change */
1375-
html {
1376-
box-sizing: border-box;
1377-
}
1378-
*, *:before, *:after {
1379-
box-sizing: inherit;
1380-
}
1381+
Add a `profile-img` class to the image tag in your **About** page.
13811382

1382-
/* clears floated child elements */
1383-
.clearfix:before,
1384-
.clearfix:after {
1385-
content: " ";
1386-
display: table;
1387-
}
1388-
.clearfix:after {
1389-
clear: both;
1390-
}
1383+
```xml
1384+
&lt;img class="profile-img" src="images/profile.jpg" alt="description of image">
13911385
```
1392-
</section>
1393-
1394-
<section class="slide" data-markdown>
1395-
##Class Exercise - classes and floats
1396-
1397-
Add a "profile-image" class to the image tag in your **About** page. Then in your css file, add a new comment block at the bottom of the page for your **About** styles, to help organize your style sheet. Then add `float` to get the text to wrap around the image.
1386+
In **styles.css**, add a new comment block at the bottom of the page for your **About** styles, to help organize your style sheet. Then add `float` to get the text to wrap around the image. Also, add some margin to the right side of the image so there is some space between the image and the text.
13981387

13991388
```css
14001389
/* ABOUT PAGE
14011390
-----------------------------------------*/
1402-
.profile-image {
1391+
.profile-img {
14031392
float: left;
1393+
margin-right: 20px;
14041394
}
14051395
```
14061396

1407-
The text floats now, but it's a little squishy. Try setting the image width to be 50% of the page and add some margin on the right to create space.
1408-
1409-
.profile-image {
1410-
float: left;
1411-
width: 50%;
1412-
margin-right: 20px;
1413-
}
1397+
That looks much better but look what happened to the quote and the footer?! Remember, all elements that come *after* floated elements will want to float too, as long as there is space for them.
14141398

1415-
That looks much better but look what happened to the quote and the footer! All elements that come after floated elements want to float too as long as there is space for them. Let's put the page back to its natural stacking order by *clearing the float*. Put the `clear` on the `blockquote` element because that's where we want things to go back to normal. Let's add a class to it as well, in the HTML.
1399+
Let's put the page back to its natural stacking order by *clearing the float*. Put the `clear:both` on the `blockquote` element because that's where we want things to go back to normal. While we're here, let's also style the text in the quote and add some spacing.
14161400

1417-
```xml
1418-
&lt;blockquote class=&quot;quote&quot;&gt;
1419-
...
1420-
&lt;/blockquote&gt;
14211401
```
1422-
```
1423-
.quote {
1424-
clear: both;
1402+
blockquote {
1403+
clear: both; /* clears the float and returns page back to normal stacking order */
1404+
text-align: center; /* center aligns the text */
1405+
padding-top: 20px; /* adds space between the blockquote & content before it */
14251406
}
1426-
```
1427-
1428-
While we're here, let's update it by center aligning the quote and add some spacing.
1429-
1430-
```
1431-
.quote {
1432-
clear: both;
1433-
text-align: center;
1434-
padding-top: 20px;
1407+
blockquote p {
1408+
font-family: "Pacifico", cursive;
1409+
font-size: 25px;
14351410
}
14361411
```
14371412

1438-
Your page should now look similar to [exercise6a-about.html](project/examples/exercise6a-about.html).
1413+
Your page should now look similar to [exercise6-about.html](project/examples/exercise6-about.html).
14391414
</section>
14401415

14411416
<section class="slide" data-markdown>

project/examples/css/exercise6.css

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* GLOBAL STYLES
22
-----------------------------------------*/
3+
34
/* apply a natural box layout model to all elements, but allowing components to change */
45
html {
56
box-sizing: border-box;
@@ -8,96 +9,71 @@ html {
89
box-sizing: inherit;
910
}
1011

11-
/* clears floated child elements */
12-
.clearfix:before,
13-
.clearfix:after {
14-
content: " ";
15-
display: table;
16-
}
17-
.clearfix:after {
18-
clear: both;
19-
}
20-
2112
body {
2213
padding: 0;
2314
margin: 0;
2415
font-family: "Open Sans", sans-serif;
2516
color: #333;
2617
}
27-
header,
28-
section {
29-
padding: 20px 30px;
30-
}
31-
section {
32-
padding-top: 125px;
33-
}
34-
3518
h1 {
3619
font-family: "Nixie One", serif;
3720
}
3821
h1, h2 {
3922
font-weight: 300;
4023
text-transform: uppercase;
41-
margin: 0;
42-
line-height: 1;
24+
margin: 0; /* removes default space */
25+
line-height: 1; /* tightens up the space between the headings */
4326
}
4427
a {
4528
color: #bf6d50;
4629
text-decoration: none;
4730
}
31+
header,
32+
section {
33+
padding: 20px 30px;
34+
}
4835
.highlight {
4936
color: #bf6d50;
5037
}
5138

39+
5240
/* HEADER
5341
-----------------------------------------*/
54-
header {
55-
background: white;
56-
border-bottom: 1px solid #eee;
57-
position: fixed;
58-
top: 0;
59-
width: 100%;
60-
}
6142
header h1 {
6243
font-size: 36px;
6344
}
6445
header h2 {
6546
font-size: 18px;
6647
}
6748

68-
69-
/* NAVIGATION MENU
70-
-----------------------------------------*/
71-
nav {
72-
position: absolute;
73-
right: 20px;
74-
top: 20px;
75-
}
49+
/* Navigation */
7650
nav ul {
77-
list-style-type: none;
78-
margin: 0;
79-
padding: 0;
51+
list-style-type: none; /* removes bullets */
52+
margin: 0; /* removes default margin */
53+
padding: 0; /* removes default padding */
8054
}
8155
nav ul li {
82-
display: inline-block;
56+
display: inline-block; /* gets the list items to line up side by side */
8357
}
8458
nav a {
59+
display: block; /* changes the element to block */
8560
padding: 5px 15px;
86-
display: block;
87-
text-transform: uppercase;
61+
text-transform: uppercase;
8862
}
8963

64+
9065
/* ABOUT PAGE
9166
-----------------------------------------*/
92-
.profile-image {
67+
.profile-img {
9368
float: left;
94-
width: 50%;
9569
margin-right: 20px;
9670
}
97-
.quote {
98-
clear: both;
71+
blockquote {
72+
clear: both; /* clears the float and returns page back to normal stacking order */
9973
text-align: center;
10074
padding-top: 20px;
10175
}
102-
103-
76+
blockquote p {
77+
font-family: "Pacifico", cursive;
78+
font-size: 25px;
79+
}

project/examples/exercise1-updated.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

project/examples/exercise1.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Page Title</title>
5+
<title>Jane Smith</title>
66
</head>
77
<body>
88
<header>
9-
<h1>Your Name Here</h1>
9+
<h1>Jane Smith</h1>
10+
<h2>Web Developer + City Girl</h2>
1011
</header>
1112

1213
<footer>
14+
<p>&#169; 2014 by jane smith</p>
1315
</footer>
1416
</body>
1517
</html>

0 commit comments

Comments
 (0)