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
Copy file name to clipboardExpand all lines: index.html
+89-94Lines changed: 89 additions & 94 deletions
Original file line number
Diff line number
Diff line change
@@ -1652,6 +1652,94 @@ <h2>Class Exercise - Positioning the Header & Nav</h2>
1652
1652
Let's finish the day with background images and forms!
1653
1653
</section>
1654
1654
1655
+
<sectionclass="slide" data-markdown>
1656
+
##Class Exercise: Background Images
1657
+
1658
+
So far, we've used `background` to add colours. We can also use it to add images. We've added images in the HTML using `img` but we can also set images as a background style using CSS.
Since our CSS file is *inside* a folder, use `../` to go *up and out* of the folder to get to the image files. Let's add it to **index.html**. Create a `.home` declaration block so this image only displays on the homepage and spans the entire page. (There are a few to choose from in your images folder.)
1665
+
1666
+
```
1667
+
.home {
1668
+
background: url(../images/background-6.jpg);
1669
+
}
1670
+
```
1671
+
1672
+
Notice how the images repeat (unless you have a really large image). We can change that with another property, `background-repeat` or just add it to the shorthand `background` property.
The image is no longer repeating but it doesn't fit the space either. Your page should look similar to the below (unless your image is larger than your resolution). We'll need to add one more property to fix this.
<p>Thanks to CSS3, we can now change the size of a background image. </p>
1699
+
<p><code>background-size</code> is the longhand property. To include it in the shorthand <code>background</code> property, it <em>must</em> be included after <code>background-position</code>, separated with the <code>/</code> character. </p>
<p>If no background position value is being used, background-size won’t work in the shorthand property so in this case, it may be less error prone to add it via the longhand property.</p>
<p>For good measure, since this image is a background image of the <code>body</code>, let's add one more rule to ensure the image covers the whole viewport and not just the height of the page content.</p>
1718
+
<pre><code>html, body {
1719
+
height: 100%;
1720
+
}
1721
+
</code></pre>
1722
+
<p><strong>Extra resources about background:</strong><br>
<p>Your page should now look similar to <ahref="project/examples/exercise8-home.html">example 8</a>.</p>
1737
+
1738
+
<divclass="presenter-notes">
1739
+
<p>You will probably be pressed for time at this point. Just explain what "cover" does and let them know there are other options available and there are additional resources at the bottom of this slide.</p>
1740
+
</div>
1741
+
</section>
1742
+
1655
1743
<sectionclass="slide" data-markdown>
1656
1744
##Forms: organizing the interface
1657
1745
@@ -1720,100 +1808,7 @@ <h2>Class Exercise - Positioning the Header & Nav</h2>
1720
1808
1721
1809
Your contact page and form should look similar to [Example 9](project/examples/exercise9-contact.html).
1722
1810
</section>
1723
-
<sectionclass="slide" data-markdown>
1724
-
##Exercise #10 - Background Images
1725
-
1726
-
Before we style the contact form, let's go over how background images work. We've added images in the HTML using `img` but we can also set images as a background style using CSS.
Since our CSS file is *inside* a folder, use `../` to go *up and out* of the folder to get to the image files. Let's add it to our Contact page. Just like the home page, add a class to the `body` tag to override or customize any styles for any element contained within the contact page.
1733
-
1734
-
```
1735
-
<body class="contact">
1736
-
```
1737
-
1738
-
```
1739
-
.contact {
1740
-
background: url(../images/your-image.jpg);
1741
-
}
1742
-
```
1743
-
1744
-
Note how the images repeat (unless you have a really large image). We can override that with another property, `background-repeat` or just add it to the shorthand `background` property.
The image is no longer repeating but it doesn't fit the space either. Thanks to CSS3, we can now change the size of a background image!
1763
-
1764
-
Let's take a look at an example of the different options: http://jsfiddle.net/zyjtde73/1/
1765
-
1766
-
`background-size` is the longhand property. To include it in the shorthand `background` property, it *must* be included after `background-position`, separated with the `/` character.
If no background position value is being used, background-size won't work in the shorthand property so in this case, it may be less error prone to add it via the longhand property.
2. Add a different background image for the home page.
1804
-
1805
-
There are a few background images in your project folder to choose from or check out these resources for free images:
1806
-
1807
-
* http://superfamous.com/
1808
-
* http://www.gratisography.com/
1809
-
* http://littlevisuals.co/
1810
-
* http://nos.twnsnd.co/
1811
-
* http://unsplash.com/
1812
-
1813
-
1814
-
Your pages should now look similar to [example 10](project/examples/exercise10-home.html).
1815
-
</section>
1816
-
1811
+
1817
1812
<sectionclass="slide">
1818
1813
<h2>Center aligning with margin</h2>
1819
1814
<p>The margin property can also be used to center align block level elements. First, a width needs to be set. Then, setting the left & right values to <code>auto</code> will find the center of the page. The <code>0</code> just refers to the top and bottom value.</p>
0 commit comments