Skip to content

Commit 92619eb

Browse files
Revised float example to better demonstrate positioning. Can't see fixed positioning well if page doesn't scroll. Added exercise to add more content.
1 parent d497ec7 commit 92619eb

3 files changed

Lines changed: 101 additions & 67 deletions

File tree

index.html

Lines changed: 92 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,11 +1144,6 @@ <h2>Box Model Review</h2>
11441144
![exercise 4 update](framework/img/workshop/exercise4-update.png)
11451145
</section>
11461146

1147-
<section class="slide title" data-markdown>
1148-
#Inline & Block
1149-
#Elements
1150-
</section>
1151-
11521147
<section class="slide" data-markdown>
11531148
##Inline vs Block Elements
11541149
By default, some HTML elements are displayed as block or inline elements.
@@ -1177,6 +1172,20 @@ <h2>Box Model Review</h2>
11771172
**Extra Resource**: [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements)
11781173
</section>
11791174

1175+
<section class="slide" data-markdown>
1176+
##CSS Display property
1177+
1178+
These default display styles can be changed using the CSS `display` property.
1179+
1180+
`display: inline` can be used to get block level elements to line up side by side, in a line.
1181+
1182+
`display: block` can be used to make inline elements behave like a block level element
1183+
1184+
`display: inline-block` is the best of both worlds. Elements will line up side by side, like inline elements and also render sizing properties like block elements.
1185+
1186+
`display: none;` will hide the element.
1187+
</section>
1188+
11801189
<section class="slide">
11811190
<h2>Block & Inline Example</h2>
11821191
<p>Suppose we had this HTML below. See how the same property and values give different results based on the element. Go ahead and update the CSS values to see how it changes.</p>
@@ -1191,26 +1200,16 @@ <h2>Block & Inline Example</h2>
11911200

11921201
<textarea class="snippet" data-subject="#inline">background: orange;
11931202
padding: 25px;
1194-
margin: 25px;</textarea>
1203+
margin: 25px;
1204+
display: ;</textarea>
11951205
<span id="inline">I'm a span so that makes me an inline element.</span>
1196-
</section>
1197-
1198-
<section class="slide" data-markdown>
1199-
##CSS Display property
12001206

1201-
These default display styles can be changed using the CSS `display` property.
1202-
1203-
`display: inline` can be used to get block level elements to line up side by side, in a line.
1204-
1205-
`display: block` can be used to make inline elements behave like a block level element
1206-
1207-
`display: inline-block` is the best of both worlds. Elements will line up side by side, like inline elements and also render sizing properties like block elements.
1208-
1209-
`display: none;` will hide the element.
1210-
1211-
Let's go back to the previous slide's example and try using the `display` property.
1207+
<div class="presenter-notes">
1208+
<p>Update the span example to inline-block and block to demonstrate the differences</p>
1209+
</div>
12121210
</section>
12131211

1212+
12141213
<section class="slide" data-markdown>
12151214
##Exercise #5 - Nav Updates (15 mins)
12161215

@@ -1382,10 +1381,25 @@ <h2>Float, Clear And Clearfix</h2>
13821381
```
13831382
</section>
13841383

1384+
<section class="slide" data-markdown>
1385+
##Add a quote
1386+
1387+
Before we practice using classes and floats, let's just add a bit more content to our **About** page. In the final example, a quote has been added for some extra personalization. Also, adding more content to the page will make it longer, therefore scrollable, which we'll need for a later exercise.
1388+
1389+
Let's add a quote using the `blockquote` and `cite` tag. Feel free to use the example below, your own or one of the lorem ipsums. Add it under the paragraphs and below the closing `section` tag.
1390+
1391+
```xml
1392+
&lt;blockquote&gt;
1393+
&lt;p&gt;The more that you read, the more things you will know. The more that you learn, the more places you'll go.&lt;/p&gt;
1394+
&lt;cite&gt;&#x2015; Dr. Seuss, I Can Read With My Eyes Shut!&lt;/cite&gt;
1395+
&lt;/blockquote&gt;
1396+
```
1397+
</section>
1398+
13851399
<section class="slide" data-markdown>
13861400
##Class Exercise - classes and floats
13871401

1388-
Add a class of "profile-image" 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** page styles. Then add a float to get the text to wrap around the image.
1402+
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. Then `float` to get the text to wrap around the image.
13891403

13901404
```css
13911405
/* ABOUT PAGE
@@ -1403,19 +1417,32 @@ <h2>Float, Clear And Clearfix</h2>
14031417
margin-right: 20px;
14041418
}
14051419

1406-
That looks much better but look what happened to 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 footer element because that's where we want things to go back to normal.
1420+
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.
14071421

1408-
```css
1409-
/* FOOTER
1410-
-----------------------------------------*/
1411-
footer {
1422+
```xml
1423+
&lt;blockquote class=&quot;quote&quot;&gt;
1424+
...
1425+
&lt;/blockquote&gt;
1426+
```
1427+
```
1428+
.quote {
1429+
clear: both;
1430+
}
1431+
```
1432+
1433+
While we're here, let's update it by center aligning the quote and add some spacing.
1434+
1435+
```
1436+
.quote {
14121437
clear: both;
1438+
text-align: center;
1439+
padding-top: 20px;
14131440
}
14141441
```
14151442

14161443
Your page should now look similar to [exercise6a-about.html](project/examples/exercise6a-about.html).
14171444
</section>
1418-
1445+
14191446
<section class="slide" data-markdown>
14201447
##Positioning in CSS
14211448

@@ -1478,14 +1505,14 @@ <h2>Position: fixed</h2>
14781505
&lt;/div&gt;</code></pre>
14791506

14801507
<textarea class="snippet" data-subject="#fixed">.container {
1481-
position:;
1508+
position: relative; /* has no effect on fixed */
14821509
}
14831510
.box {
14841511
width: 100px;
14851512
height: 100px;
14861513
background: blue;
14871514
position: fixed;
1488-
top:;
1515+
bottom: 0;
14891516
}</textarea>
14901517

14911518
<div id="fixed">
@@ -1496,43 +1523,46 @@ <h2>Position: fixed</h2>
14961523
</section>
14971524

14981525
<section class="slide" data-markdown>
1499-
##Exercise #6 - Positioning the Header & Nav
1526+
##Class Exercise - Positioning the Header & Nav
15001527

1501-
1. Position the nav to the top right of the header element.
1502-
1503-
```
1504-
nav {
1505-
position: absolute;
1506-
right: 20px;
1507-
top: 20px;
1508-
}
1509-
```
1528+
Position the nav to the top right of the header element.
15101529

1511-
1. The entire header itself should be set to fixed positioning so when you scroll the page, it stays fixed at the top.
1512-
```
1513-
header {
1514-
position: fixed;
1515-
}
1516-
```
1517-
Notice that adding this property changes the page. When you position an element, it automatically becomes the width of its content. Set the width to 100% so it becomes as wide as the browser.
1530+
header {
1531+
position: relative;
1532+
}
1533+
nav {
1534+
position: absolute;
1535+
right: 20px;
1536+
top: 20px;
1537+
}
15181538

1519-
Also, set the background to white so the content underneath doesn't show through when you scroll the page. Add a border on the bottom to create a separation of the header from the page content.
15201539

1521-
```
1522-
header {
1523-
position: fixed;
1524-
width: 100%;
1525-
background: white;
1526-
}
1527-
```
1528-
1. Positioning takes the element out of the natural stacking order. See how the profile picture "jumped" underneath the header when position: fixed was applied? It's because it doesn't "see" that there's an element before it, so it wants to slide up to the next available slot. Add some padding on the top of the section element to push the content down below the fixed header.
1529-
```
1530-
section {
1531-
padding-top: 125px;
1532-
}
1533-
```
1540+
The *entire* header itself should be set to fixed positioning so when you scroll the page, it stays fixed at the top.
1541+
1542+
header {
1543+
position: fixed;
1544+
}
1545+
1546+
Notice that adding this property changes the page. When you position an element, it automatically becomes the width of its content. Set the width to 100% so it becomes as wide as the browser.
1547+
1548+
Also, set the background to white so the content underneath doesn't show through when you scroll the page. Add a border on the bottom to create a separation of the header from the page content.
1549+
1550+
1551+
header {
1552+
position: fixed;
1553+
width: 100%;
1554+
background: white;
1555+
border-bottom: 1px solid #eee;
1556+
}
1557+
1558+
Positioning takes the element out of the natural stacking order. See how the profile picture "jumped" underneath the header when position: fixed was applied? It's because it doesn't "see" that there's an element before it, so it wants to slide up to the next available slot. Add some padding on the top of the section element to push the content down below the fixed header.
1559+
1560+
section {
1561+
padding-top: 125px;
1562+
}
1563+
15341564

1535-
Your page should look like [example 6](project/examples/exercise6-about.html). Note how the header looks the same on all three pages now... except the home page! Where did the navigation disappear off to?
1565+
Your page should look like [example 6](project/examples/exercise6-about.html). Note how the header looks the same on all three pages now... except the home page! Where did the navigation disappear off to?
15361566
</section>
15371567

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

project/examples/css/exercise6a.css

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ nav a {
7676
width: 50%;
7777
margin-right: 20px;
7878
}
79-
80-
81-
/* FOOTER
82-
-----------------------------------------*/
83-
footer {
79+
.quote {
8480
clear: both;
81+
text-align: center;
82+
padding-top: 20px;
8583
}
84+

project/examples/exercise6a-about.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ <h2>Hello!</h2>
2828
<p>[Personal summary or life story here] Lorem ipsum dolor sit amet, consectetur adipisicing elit. Debitis laboriosam officia blanditiis tempora sit fugiat molestiae iusto impedit ipsa cum, asperiores laborum, esse, doloribus explicabo! Autem, distinctio provident itaque non.</p>
2929
<p>Links to stuff about you, if needed. <a href="#">Link example</a> and <a href="#">another link example</a>.</p>
3030
<p>Or another paragraph! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque maiores dolor id voluptatibus iure eum hic similique, cum impedit possimus nesciunt deleniti atque fugiat. Nesciunt in ipsum voluptatem debitis nihil!</p>
31+
32+
<blockquote class="quote">
33+
<p>The more that you read, the more things you will know. The more that you learn, the more places you'll go.</p>
34+
<cite>― Dr. Seuss, I Can Read With My Eyes Shut!</cite>
35+
</blockquote>
3136
</section>
3237

3338
<footer>

0 commit comments

Comments
 (0)