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
Let's go back to the previous slide's example and try using the `display` property.
1214
1214
</section>
1215
-
1216
-
<sectionclass="slide" data-markdown>
1217
-
##CSS Float Property
1218
-
1219
-
Remember, block-style HTML elements like `<p>`, `<div>` and `<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.
1220
-
1221
-
CSS floats can float elements left or right.
1222
-
1223
-
**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.
1224
-
1225
-
**Also**, if no width is set, the element will float but the width will automatically be the width of its content.
1226
-
</section>
1227
-
1228
-
<sectionclass="slide centered">
1229
-
<h2>Huh?</h2>
1230
-
<imgsrc="framework/img/workshop/huh.gif">
1231
-
1232
-
<pclass="delayed">Not to worry, we can fix it.</p>
1233
-
</section>
1234
-
1235
-
<sectionclass="slide" data-markdown>
1236
-
##Float, Clear And Clearfix
1237
-
1238
-
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.
1239
-
1240
-
One of the most confusing CSS concepts is when to use the different techniques, `clear: both` or the `.clearfix` class.
1241
-
1242
-
Rule of thumb: if there's is an element that *follows* the floated element, apply `clear: both` to that element. This will clear the float. If all the elements need to be floated, apply the `clearfix` to the parent element to force clear the children.
1243
-
1244
-
Let's look at an example here: http://jsfiddle.net/unjcxses/
1245
-
1246
-
Want to know more about the clearfix trick and clearing floats? Here you go:
Follow the instructions below. Check these changes on either the About or Contact page. The Home page will be styled later since it's different.
1281
1246
1282
-
Though all the CSS is listed, try adding in one line at a time to see and understand what each property does. Feel free to leave comments for yourself in the code to explain what each line is doing!
1283
-
1284
-
There's a couple more concepts to go through to finish styling the header and nav, so your page should look like [example 5](project/examples/exercise5-about.html).
1247
+
Though all the CSS is listed, try adding in one line at a time to see and understand what each property does. Feel free to leave comments for yourself in the code to explain what each line is doing.
1285
1248
1286
1249
1. Remove default list styles and get each item to line up in a line.
1287
1250
```
@@ -1303,7 +1266,9 @@ <h2>Huh?</h2>
1303
1266
text-transform: uppercase;
1304
1267
}
1305
1268
```
1306
-
1269
+
1270
+
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).
1271
+
1307
1272
**Bonus**:
1308
1273
If you have some extra time, try adding some comments to your CSS to organize it. See [sample here](project/examples/css/exercise5.css).
1309
1274
Find a background image for later or choose one from the **images** folder. Here are some resources:
@@ -1314,6 +1279,141 @@ <h2>Huh?</h2>
1314
1279
* http://nos.twnsnd.co/
1315
1280
* http://unsplash.com/
1316
1281
</section>
1282
+
1283
+
<sectionclass="slide" data-markdown>
1284
+
##Class Selectors
1285
+
1286
+
HTML provides ways to attach extra identifying information to target elements in a more specific way.
1287
+
1288
+
A `class` *attribute* can be added to any element but the value is defined by you. The class can then be used as a selector to apply styles to any element that references the class attribute. Classes can be used multiple times on the same page. In CSS, classes are denoted by a leading period.
1289
+
1290
+
```xml
1291
+
<p>Regular text</p>
1292
+
<p class="special">Special text here.</p>
1293
+
```
1294
+
```
1295
+
p {
1296
+
color: red;
1297
+
font-family: Georgia, "Times New Roman", serif;
1298
+
}
1299
+
.special {
1300
+
text-transform: uppercase;
1301
+
}
1302
+
```
1303
+
</section>
1304
+
<sectionclass="slide" data-markdown>
1305
+
##Mini-Exercise
1306
+
1307
+
Let's create a class called `highlight` and assign it an accent colour. Add this class to any element and it will apply this style.
1308
+
1309
+
```
1310
+
.highlight {
1311
+
color: #bf6d50;
1312
+
}
1313
+
```
1314
+
1315
+
Using a span tag, wrap it around your first name on the homepage and apply this class.
Now it looks like this! Add this anywhere you want some highlighted text!
1322
+
1323
+

1324
+
</section>
1325
+
<sectionclass="slide" data-markdown>
1326
+
##id Selectors
1327
+
1328
+
`id` *attributes* are similar to `class` *attributes* because it can also be added to any element.
1329
+
1330
+
However, it can be used only **once** per page. IDs should be reserved for significant style rules. Some developers prefer not to use IDs at all for CSS styling because of the specificity rules and because classes can be used once or multiple times, making it more flexible.
1331
+
1332
+
In CSS, IDs are denoted by a leading hash symbol (`#`).
1333
+
```
1334
+
#header {
1335
+
width: 800px;
1336
+
}
1337
+
```
1338
+
ids can also be used to link within the same page. [Read more about this technique here](http://www.webweaver.nu/html-tips/link-within-a-page.shtml).
1339
+
</section>
1340
+
<sectionclass="slide" data-markdown>
1341
+
##class and id Names
1342
+
1343
+
When choosing a class or id name, choose a descriptive name and do not use spaces. Hyphens (-), underscores (_) and camel case are acceptable. CSS is also case sensitive, so while these three examples look similar, CSS will read these as three different classes so it's important (for you own sanity) to pick one style and be consistent.
1344
+
1345
+
```
1346
+
class="content-wrapper"
1347
+
class="content_wrapper"
1348
+
class="contentWrapper"
1349
+
```
1350
+
</section>
1351
+
1352
+
<sectionclass="slide" data-markdown>
1353
+
##CSS Float Property
1354
+
1355
+
Remember, block-style HTML elements like `<p>`, `<div>` and `<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.
1356
+
1357
+
CSS floats can float elements left or right.
1358
+
1359
+
**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.
1360
+
1361
+
**Also**, if no width is set, the element will float but the width will automatically be the width of its content.
1362
+
</section>
1363
+
1364
+
<sectionclass="slide centered">
1365
+
<h2>Huh?</h2>
1366
+
<imgsrc="framework/img/workshop/huh.gif">
1367
+
1368
+
<pclass="delayed">Not to worry, we can fix it.</p>
1369
+
</section>
1370
+
1371
+
<sectionclass="slide" data-markdown>
1372
+
##Float, Clear And Clearfix
1373
+
1374
+
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.
1375
+
1376
+
One of the most confusing CSS concepts is when to use the different techniques, `clear: both` or the `.clearfix` class.
1377
+
1378
+
Rule of thumb: if there's is an element that *follows* the floated element, apply `clear: both` to that element. This will clear the float. If all the elements need to be floated, apply the `clearfix` to the parent element to force clear the children.
1379
+
1380
+
Let's look at an example here: http://jsfiddle.net/unjcxses/
1381
+
1382
+
Want to know more about the clearfix trick and clearing floats? Here you go:
1. Add a class of "profile-image" to the image tag in your **About** page. Add a left float to get the text to wrap around it.
1391
+
1392
+
```
1393
+
.profile-image {
1394
+
float: left;
1395
+
}
1396
+
```
1397
+
1. 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.
1398
+
1399
+
```
1400
+
.profile-image {
1401
+
float: left;
1402
+
width: 50%;
1403
+
margin-right: 20px;
1404
+
}
1405
+
```
1406
+
1. 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. We put the `clear` on the footer because that's where we want things to go back to normal.
1407
+
1408
+
```
1409
+
footer {
1410
+
clear: both;
1411
+
}
1412
+
```
1413
+
1414
+
Your page should now look similar to [exercise6a-about.html](project/examples/exercise6a-about.html).
1415
+
</section>
1416
+
1317
1417
<sectionclass="slide" data-markdown>
1318
1418
##Positioning in CSS
1319
1419
@@ -1394,77 +1494,7 @@ <h2>Position: fixed</h2>
1394
1494
</section>
1395
1495
1396
1496
<sectionclass="slide" data-markdown>
1397
-
##Class Selectors
1398
-
1399
-
HTML gives us a couple ways to attach extra identifying information to target elements in a way that is more specific. Two *attributes* called `class` and `id` can be used.
1400
-
1401
-
A `class` *attribute* can be added to any element but the value is defined by you. The class can then be used as a selector to apply styles to any element that references the class attribute.
1402
-
1403
-
Classes can be used multiple times on the same page. In CSS, classes are denoted by a leading period.
1404
-
1405
-
```xml
1406
-
<p>Regular text</p>
1407
-
<p class="special">Special text here.</p>
1408
-
```
1409
-
```
1410
-
p {
1411
-
color: red;
1412
-
font-family: Georgia, "Times New Roman", serif;
1413
-
}
1414
-
.special {
1415
-
text-transform: uppercase;
1416
-
}
1417
-
```
1418
-
</section>
1419
-
<sectionclass="slide" data-markdown>
1420
-
##Mini-Exercise
1421
-
1422
-
Let's create a class called `highlight` and assign it an accent colour. I can now add this class to any element and it will apply this style.
1423
-
1424
-
```
1425
-
.highlight {
1426
-
color: #bf6d50;
1427
-
}
1428
-
```
1429
-
1430
-
Using a span tag, wrap it around your first name on the homepage and apply this class.
Now it looks like this! Add this anywhere you want some highlighted text!
1437
-
1438
-

1439
-
</section>
1440
-
<sectionclass="slide" data-markdown>
1441
-
##id Selectors
1442
-
1443
-
`id` *attributes* are similar to `class` *attributes* because it can also be added to any element and given any value.
1444
-
1445
-
However, it can be used only **once** per page. IDs should be reserved for significant style rules. Some developers prefer not to use IDs at all for CSS styling because of the specificity rules and because classes can be used once or multiple times, making it more flexible.
1446
-
1447
-
In CSS, IDs are denoted by a leading hash symbol (`#`).
1448
-
```
1449
-
#header {
1450
-
width: 800px;
1451
-
}
1452
-
```
1453
-
</section>
1454
-
<sectionclass="slide" data-markdown>
1455
-
##class and id Names
1456
-
1457
-
When choosing a class or id name, choose a descriptive name and do not use spaces. Hyphens (-), underscores (_) and camel case are acceptable. CSS is also case sensitive, so while these three examples look similar, CSS will read these as three different classes so it's important (for you own sanity) to pick one style and be consistent.
1458
-
1459
-
```
1460
-
class="content-wrapper"
1461
-
class="content_wrapper"
1462
-
class="contentWrapper"
1463
-
```
1464
-
</section>
1465
-
1466
-
<sectionclass="slide" data-markdown>
1467
-
##Exercise #6 - About, Header & Nav, pt 2
1497
+
##Exercise #6 - Positioning the Header & Nav
1468
1498
1469
1499
1. Position the nav to the top right of the header element.
1470
1500
@@ -1499,30 +1529,6 @@ <h2>Position: fixed</h2>
1499
1529
padding-top: 125px;
1500
1530
}
1501
1531
```
1502
-
1. Add a class of "profile-image" to the image tag in your about page. Add a left float to get the text to wrap around it.
1503
-
1504
-
```
1505
-
.profile-image {
1506
-
float: left;
1507
-
}
1508
-
```
1509
-
1. The text floats now, but it's a little squishy. Try setting the image width to be 50% off the page and add some margin on the right to create space.
1510
-
1511
-
```
1512
-
.profile-image {
1513
-
float: left;
1514
-
width: 50%;
1515
-
margin-right: 20px;
1516
-
}
1517
-
```
1518
-
1. 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 it's natural stacking order by clearing the float on the footer because that's where we want things to go back to normal.
1519
-
1520
-
```
1521
-
footer {
1522
-
clear: both;
1523
-
}
1524
-
```
1525
-
1526
1532
1527
1533
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?
0 commit comments