Skip to content

Commit 2bad3df

Browse files
Added example info about headings exercise, revised inline/block content.
1 parent 0e56a6f commit 2bad3df

2 files changed

Lines changed: 90 additions & 73 deletions

File tree

103 KB
Loading

index.html

Lines changed: 90 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ <h2>Padding and Margin</h2>
10001000
<li>1 value means the same amount of padding on all sides</li>
10011001
</ul>
10021002

1003-
Let's try changing some of the margin & padding settings below using 1-4 values and see what happens!
1003+
<p>Let's try changing some of the margin & padding settings below using 1-4 values and see what happens!</p>
10041004

10051005
<textarea class="snippet" data-subject="#padding">background: lightblue;
10061006
width: 500px;
@@ -1069,7 +1069,9 @@ <h2>Box Model Review</h2>
10691069

10701070
Luckily, there’s a fix for this. Enter the [box-sizing: border-box](http://www.paulirish.com/2012/box-sizing-border-box-ftw/) fix ftw!
10711071

1072-
It is recommended to add this snippet to all your projects. Let's add it to our CSS file now, to the very top of the file, since it's a global style.
1072+
It is recommended to add this snippet to all your projects. By adding this fix, you won't have to worry about `padding` and `border` increasing the size of your elements.
1073+
1074+
Let's add it to our CSS file now, to the very top of the file, since it's a global style.
10731075

10741076
```
10751077
/* apply a natural box layout model to all elements, but allowing components to change */
@@ -1082,9 +1084,29 @@ <h2>Box Model Review</h2>
10821084
```
10831085
</section>
10841086
<section class="slide" data-markdown>
1085-
##Class Exercise - headings and padding
1087+
##Class Exercise - headings and spacing
1088+
1089+
For this next exercise, we are going to use `margin`, `padding`, `line-height` and `font-size` to update the heading styles and spacing of the content.
1090+
1091+
These changes will make the page go from the example on the left, to the one on the right.
1092+
1093+
![exercise 5](framework/img/workshop/exercise-heading-spacing.jpg)
1094+
</section>
1095+
<section class="slide" data-markdown>
1096+
##Class Exercise - headings and spacing
1097+
1098+
Let's focus on checking these updates on your **About** page for this exercise.
1099+
1100+
Add padding to the `header` and `section` so there's an equal amount of space around the content blocks.
1101+
1102+
```
1103+
header,
1104+
section {
1105+
padding: 20px 30px;
1106+
}
1107+
```
10861108

1087-
Let's focus on checking these updates on your **About** page for this exercise. Remove the default space from the `h1` and `h2` and set the line-height. Add it to the the existing `h1,h2` declaration block.
1109+
Remove the default space from the `h1` and `h2` and set the line-height. Add it to the the existing `h1,h2` declaration block.
10881110

10891111
```
10901112
h1, h2 {
@@ -1094,56 +1116,77 @@ <h2>Box Model Review</h2>
10941116
line-height: 1; /* tightens up the space between the headings */
10951117
}
10961118
```
1097-
Set the size for only the headings in the header.
1119+
Set the size of the headings **in the header**. We will use a **descendant selector** for this (more on this soon). We can also add a comment block for this section to organize the css.
10981120

1099-
```
1121+
```css
1122+
/* HEADER
1123+
-----------------------------------------*/
11001124
header h1 {
11011125
font-size: 36px;
11021126
}
11031127
header h2 {
11041128
font-size: 18px;
11051129
}
11061130
```
1131+
</section>
1132+
1133+
<section class="slide" data-markdown>
1134+
##Descendant selectors
1135+
1136+
Matches any element that is a descendant (nested tag) of the element declared before it.
11071137

1108-
Add padding to `header` and `section` so there's an equal amount of space around the content blocks.
1138+
```css
1139+
p a {
1140+
/* targets only anchor link tags nested inside of a p tag */
1141+
}
1142+
```
1143+
**Protip!** Just like [Inception](http://www.imdb.com/title/tt1375666/), don't go more than three levels deep.
11091144

11101145
```
1111-
header,
1112-
section {
1113-
padding: 20px 30px;
1146+
nav ul li a span {
1147+
/* NOOOOOOOOOOO */
11141148
}
11151149
```
1116-
Your page should look similar to this:
11171150

1118-
![exercise 4 update](framework/img/workshop/exercise4-update.png)
1119-
</section>
1151+
Feel free to skip a level but be mindful of specificity rules. For example, `nav ul li a` would override `nav a` because it's more specific. It’s usually easier to start with generic selectors and make them more specific, as needed, rather than starting with very specific selectors and adding extra markup or classes to try to override the styles.
1152+
</section>
11201153

1121-
<section class="slide" data-markdown>
1122-
##Inline vs Block Elements
1123-
By default, some HTML elements are displayed as block or inline elements.
1124-
1125-
###Block Elements
1126-
1127-
* takes up 100% width of its container, no matter how long the actual content is
1128-
* will be the same height as its content
1129-
* always starts on a new line
1130-
* can wrap other block level elements or inline elements
1131-
* can apply sizing related CSS to it (margin, padding, height, width)
1154+
<section class="slide">
1155+
<h2>Block vs Inline Elements</h2>
11321156

1133-
###Inline Elements
1157+
<p>Right now, our navigation list stacks on top of each other. That’s because they are <strong>block</strong> elements.<br>
1158+
By default, some HTML elements are displayed as block or inline elements.</p>
11341159

1135-
* will be the height and width of its content
1136-
* always appears "in a line" with other inline level elements
1137-
* can wrap other inline elements but cannot wrap block level elements *except* `&lt;a&gt;` tags. This is only valid with an HTML5 doctype.
1138-
* does not render CSS height and width at all, will apply margin and padding but with unexpected results
1160+
<h3>Block Elements</h3>
1161+
<ul>
1162+
<li>takes up 100% width of its container, no matter how long the actual content is</li>
1163+
<li>will be the same height as its content</li>
1164+
<li>always starts on a new line</li>
1165+
<li>can wrap other block level elements or inline elements</li>
1166+
<li>can apply sizing related CSS to it (margin, padding, height, width)</li>
1167+
</ul>
11391168

1140-
###Inline-block
1169+
<textarea class="snippet" data-subject="#block">background: lightblue;
1170+
padding: 0px;
1171+
margin: 0px;</textarea>
1172+
<div id="block">I'm a div so that makes a me a block element.</div>
1173+
</section>
1174+
1175+
<section class="slide">
1176+
<h2>Block vs Inline Elements</h2>
1177+
<h3>Inline Elements</h3>
11411178

1142-
* best of both worlds
1143-
* floats left and is the size & height of its content, like inline elements
1144-
* accepts height and width values like block elements
1179+
<ul>
1180+
<li>will be the height and width of its content</li>
1181+
<li>always appears “in a line” with other inline level elements</li>
1182+
<li>can wrap other inline elements but cannot wrap block level elements <em>except</em> <code>&amp;lt;a&amp;gt;</code> tags. This is only valid with an HTML5 doctype.</li>
1183+
<li>does not render CSS height and width at all, will apply margin and padding but with unexpected results</li>
1184+
</ul>
11451185

1146-
**Extra Resource**: [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements)
1186+
<textarea class="snippet" data-subject="#inline">background: orange;
1187+
padding: 0px;
1188+
margin: 0px;</textarea>
1189+
<span id="inline">I'm a span. I'm an inline element.</span>
11471190
</section>
11481191

11491192
<section class="slide" data-markdown>
@@ -1159,37 +1202,10 @@ <h2>Box Model Review</h2>
11591202

11601203
`display: none;` will hide the element.
11611204
</section>
1162-
1163-
<section class="slide">
1164-
<h2>Block & Inline Example</h2>
1165-
<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>
1166-
1167-
<pre><code class="xml">&lt;div&gt;I'm a div so that makes a me a block element.&lt;/div&gt;
1168-
&lt;span&gt;I'm a span so that makes me an inline element.&lt;/span&gt;</code></pre>
1169-
1170-
<textarea class="snippet" data-subject="#block">background: lightblue;
1171-
padding: 25px;
1172-
margin: 25px;</textarea>
1173-
<div id="block">I'm a div so that makes a me a block element.</div>
1174-
1175-
<textarea class="snippet" data-subject="#inline">background: orange;
1176-
padding: 25px;
1177-
margin: 25px;
1178-
display: ;</textarea>
1179-
<span id="inline">I'm a span so that makes me an inline element.</span>
1180-
1181-
<div class="presenter-notes">
1182-
<p>Update the span example's display property to inline-block and block to demonstrate the differences.</p>
1183-
</div>
1184-
</section>
1185-
1186-
11871205
<section class="slide" data-markdown>
1188-
##Exercise #5 - Nav Updates (15 mins)
1189-
1190-
Follow the instructions below. Check these changes on either the About or Contact page. The Home page will be styled later since it has a different style from these two pages.
1206+
##Exercise #5 - Nav Updates (10 mins)
11911207

1192-
Though all the CSS is listed below, try adding in one line at a time to see and understand what each property does. Leave comments for yourself in the code to explain what each line is doing if needed and use comments to organize your code. See [sample here](project/examples/css/exercise5.css).
1208+
Try adding in one line of the below CSS at a time to see and understand what each property does. Leave comments for yourself in the code to explain what each line is doing if needed and use comments to organize your code. See [sample here](project/examples/css/exercise5.css).
11931209

11941210
Remove default list styles and get each item to line up in a line.
11951211

@@ -1201,8 +1217,18 @@ <h2>Block & Inline Example</h2>
12011217
nav ul li {
12021218
display: inline-block; /* gets the list items to line up side by side */
12031219
}
1220+
**Bonus**:
1221+
If you have some extra time, find a background image for later or choose one from the **images** folder. Here are some resources:
1222+
1223+
* http://superfamous.com/
1224+
* http://www.gratisography.com/
1225+
* http://littlevisuals.co/
1226+
* http://nos.twnsnd.co/
1227+
* http://unsplash.com/
1228+
</section>
12041229

1205-
Add some space around the links. It's better to put padding on the anchor link rather the the list item because padding adds space on the *inside*. Putting it on the link with make the click area bigger.
1230+
<section class="slide" data-markdown>
1231+
Add some space around the links. It's better to put padding on the anchor link rather the the list item because padding adds space on the *inside*. Putting it on the link with make the click area bigger.
12061232

12071233
nav a {
12081234
display: block; /* changes the element to block */
@@ -1211,15 +1237,6 @@ <h2>Block & Inline Example</h2>
12111237
}
12121238

12131239
There's a few more concepts to go through to finish styling the header and nav. This is what your page should look like so far: [example 5 about](project/examples/exercise5-about.html) and [example 5 contact](project/examples/exercise5-contact.html).
1214-
1215-
**Bonus**:
1216-
If you have some extra time, find a background image for later or choose one from the **images** folder. Here are some resources:
1217-
1218-
* http://superfamous.com/
1219-
* http://www.gratisography.com/
1220-
* http://littlevisuals.co/
1221-
* http://nos.twnsnd.co/
1222-
* http://unsplash.com/
12231240
</section>
12241241

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

0 commit comments

Comments
 (0)