You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
1071
1071
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.
1073
1075
1074
1076
```
1075
1077
/* apply a natural box layout model to all elements, but allowing components to change */
@@ -1082,9 +1084,29 @@ <h2>Box Model Review</h2>
1082
1084
```
1083
1085
</section>
1084
1086
<sectionclass="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.
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
+
```
1086
1108
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.
1088
1110
1089
1111
```
1090
1112
h1, h2 {
@@ -1094,56 +1116,77 @@ <h2>Box Model Review</h2>
1094
1116
line-height: 1; /* tightens up the space between the headings */
1095
1117
}
1096
1118
```
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.
1098
1120
1099
-
```
1121
+
```css
1122
+
/* HEADER
1123
+
-----------------------------------------*/
1100
1124
header h1 {
1101
1125
font-size: 36px;
1102
1126
}
1103
1127
header h2 {
1104
1128
font-size: 18px;
1105
1129
}
1106
1130
```
1131
+
</section>
1132
+
1133
+
<sectionclass="slide" data-markdown>
1134
+
##Descendant selectors
1135
+
1136
+
Matches any element that is a descendant (nested tag) of the element declared before it.
1107
1137
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.
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>
1120
1153
1121
-
<sectionclass="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
+
<sectionclass="slide">
1155
+
<h2>Block vs Inline Elements</h2>
1132
1156
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>
1134
1159
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* `<a>` 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>
<divid="block">I'm a div so that makes a me a block element.</div>
1173
+
</section>
1174
+
1175
+
<sectionclass="slide">
1176
+
<h2>Block vs Inline Elements</h2>
1177
+
<h3>Inline Elements</h3>
1141
1178
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>&lt;a&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>
<spanid="inline">I'm a span. I'm an inline element.</span>
1147
1190
</section>
1148
1191
1149
1192
<sectionclass="slide" data-markdown>
@@ -1159,37 +1202,10 @@ <h2>Box Model Review</h2>
1159
1202
1160
1203
`display: none;` will hide the element.
1161
1204
</section>
1162
-
1163
-
<sectionclass="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><codeclass="xml"><div>I'm a div so that makes a me a block element.</div>
1168
-
<span>I'm a span so that makes me an inline element.</span></code></pre>
<spanid="inline">I'm a span so that makes me an inline element.</span>
1180
-
1181
-
<divclass="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
-
1187
1205
<sectionclass="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)
1191
1207
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).
1193
1209
1194
1210
Remove default list styles and get each item to line up in a line.
display: inline-block; /* gets the list items to line up side by side */
1203
1219
}
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>
1204
1229
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
+
<sectionclass="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.
1206
1232
1207
1233
nav a {
1208
1234
display: block; /* changes the element to block */
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:
0 commit comments