Skip to content

Commit 1683ce7

Browse files
Moved extra form styles lesson.
1 parent 79e079e commit 1683ce7

File tree

5 files changed

+305
-123
lines changed

5 files changed

+305
-123
lines changed

framework/extras-form-controls.html renamed to framework/extras-form-styles.html

Lines changed: 80 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,98 @@
1616

1717
<!-- Workshop-specific styles -->
1818
<link rel="stylesheet" href="css/workshop.css">
19-
20-
<!-- Takes care of CSS3 prefixes! -->
21-
<script src="scripts/prefixfree.min.js"></script>
2219
</head>
2320

2421
<body>
2522

2623
<base target="_blank">
27-
2824
<main>
29-
<section class="slide" data-markdown>
30-
##Form controls: putting it all together
31-
32-
`input` elements are used to allow the user to type in their information and is used with a `type` attribute to determine the kind of information it is.
25+
<section class="slide" data-markdown>
26+
##Contact Page: Add a background image
3327

34-
The `label` tags are used to label the input.
28+
Add a class of `contact` to the `body` tag in the HTML. Just like for the home page, we'll use this to apply a background image to the `body` only for the **Contact** page.
3529

36-
The `name` attribute is used to label the fields when sending the form data to the server.
37-
38-
The `for` and `id` attributes are used to associate the label to the input and should have matching values.
30+
```
31+
&lt;body class="contact">
32+
```
3933

40-
A form can contain any HTML markup (paragraphs, lists, etc.) in addition to form specific HTML tags.
34+
Add a new comment block to organize your page specific styles.
4135

42-
[Each part of a form is considered a paragraph](http://dev.w3.org/html5/spec-LC/forms.html#forms) and can be separated using `&lt;p>` elements.
36+
```css
37+
/* CONTACT PAGE
38+
-----------------------------------------*/
39+
.contact {
40+
background: url(../images/background-8.jpg) no-repeat;
41+
background-size: cover;
42+
}
43+
```
44+
Your page should now look similar to this:
4345

44-
**Further reading: ** [MDN forms](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms)
46+
![contact page bg](img/workshop/contact-bg.png)
4547
</section>
48+
49+
<section class="slide">
50+
<h2>Center aligning with margin</h2>
51+
<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 &amp; 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>
52+
53+
<p>If the css looked like this:</p>
54+
55+
<pre><code>.box {
56+
background-color: lightblue;
57+
height: 100px;
58+
width: 600px;
59+
margin: 0 auto;
60+
}</code></pre>
61+
62+
<p>The element would render like this example below. Notice how it always stays in the middle of the page, even if you minimize or maximize the browser.</p>
63+
64+
<div style="background-color: lightblue; height: 100px; width: 600px; margin: 0 auto;">box</div>
65+
</section>
66+
67+
<section class="slide" data-markdown>
68+
##Styling the form
69+
70+
In the markup for the form, a class of `contact-form` was included in the `form` tag to be used for styling since all the form elements are contained within it.
71+
72+
Set a width for the form and center align it on the page. Also add a background colour to see the text more clearly over the image.
73+
74+
```
75+
.contact-form {
76+
width: 600px;
77+
margin: 10px auto;
78+
background: white;
79+
}
80+
```
81+
82+
Add some padding to `contact-form` to keep the text from going right up to the edge. Also try adding the CSS property `border-radius` to add some rounded corners.
83+
84+
```
85+
.contact-form {
86+
width: 600px;
87+
margin: 10px auto;
88+
background: white;
89+
padding: 20px;
90+
border-radius: 4px;
91+
}
92+
```
93+
94+
To get the input and textarea to span all the way across the form, we can set the width to 100% so it takes up the entire width of the form. It's also possible to override the default border styles too. Add height to the textarea just to give more room for the user to type a message.
95+
96+
```
97+
input,
98+
textarea {
99+
width: 100%;
100+
border: 1px solid #ccc;
101+
padding: 5px;
102+
}
103+
textarea {
104+
height: 100px;
105+
}
106+
```
107+
Your form should look similar to the [contact-page-styles.html](../project/examples/contact-page-styles.html) example.
108+
109+
There's so much more you can do with forms. Check out this project's final css file to see what other changes you can add or take a look at this resource: http://code.tiffbits.com/css3-form-styling-cheat-sheet/
110+
</section>
46111
</main><!-- cls main section -->
47112

48113
<footer>

framework/img/workshop/contact-bg.png

599 KB
Loading

index.html

Lines changed: 20 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,122 +1787,34 @@ <h2>Class Exercise #9 - Contact Form</h2>
17871787
<p>Your contact page and form should look similar to <a href="project/examples/exercise9-contact.html">Example 9</a>.</p>
17881788

17891789
<div class="presenter-notes">
1790-
<p>Give an general overview of what each from control is used for as you are adding in the code. There's further resources available in the next slide.</p>
1790+
<p>Give a general overview of what each from control is used for as you are adding in the code. There's further resources available in the homework/next steps section.</p>
17911791

1792-
<p>This will be the official last exercise for the day. Though there are plenty of other lessons in the next steps/homework section. If you find yourself with extra time, congratulate the class on picking up the concepts so well and either give them free time to tweak their projects, pick one of the homework assignments to go through together. Save some time to briefly cover the next steps.</p>
1792+
<p>This will be the official last exercise for the day. If you find yourself with extra time, congratulate the class on picking up the concepts so well and either give them free time to tweak their projects or pick one of the homework assignments to go through together. Save some time to briefly cover the next steps.</p>
17931793
</div>
17941794
</section>
17951795

1796-
<!-- <section class="slide" data-markdown>
1797-
##Forms
1798-
1799-
Forms are used to capture information from a user. The information processing and form submission usually requires the use of a server-side language such as PHP, Ruby or Python. But there are different services available to help do the processing for us without writing any of these languages!
1800-
1801-
Today we're going to use http://forms.brace.io/ to submit our form info. Through this service, the information will be forwarded to your email. Simple!
1802-
1803-
All forms begin with the `form` element and requires
1804-
two attributes, `method` (defines how the form will communicate with the web server) and `action` (provides the file path to where the form script is processed after the form is submitted.
1805-
1806-
Since we're using a 3rd party service, the `action` value is their url *and* the email you want the form to be submitted to.
1807-
1808-
```xml
1809-
&lt;form method="POST" action="http://forms.brace.io/hello@email.com">
1810-
...
1811-
&lt;/form>
1812-
```
1813-
</section> -->
1796+
<div class="slide centered" data-markdown>
1797+
##And we're done!
18141798

1815-
<!-- <section class="slide">
1816-
<h2>Class Exercise #9 - Contact Form</h2>
1799+
![what?](http://i.imgur.com/RpCC4.gif)
18171800

1818-
<p>On your contact page, under the header, create a new <code>&lt;section&gt;</code> tag. Add the below markup <em>in between</em> the <code>section</code> element.</p>
1819-
<p>Brace.io requires that you verify your email first. The verification email will be sent on the <strong>first</strong> form submit so make sure you test your form first!</p>
1820-
1821-
<pre><code class="xml">&lt;section&gt;
1822-
&lt;form class="contact-form" action="http://forms.brace.io/hello@your-email.com" method="POST"&gt;
1823-
&lt;h2&gt;Let's meet for coffee!&lt;/h2&gt;
1824-
1825-
&lt;p&gt;Send me a message at &lt;a href="mailto:hello@your-email.com"&gt;hello@your-email.com&lt;/a&gt;,
1826-
use the form below or say "hi!" on one of my social networks.&lt;/p&gt;
1827-
&lt;p&gt;
1828-
&lt;label for="name"&gt;Name&lt;/label&gt;
1829-
&lt;input id="name" type="text" name="name"&gt;
1830-
&lt;/p&gt;
1831-
&lt;p&gt;
1832-
&lt;label for="email"&gt;Email&lt;/label&gt;
1833-
&lt;input id="email" type="email" name="replyto"&gt;
1834-
&lt;/p&gt;
1835-
&lt;p&gt;
1836-
&lt;label for="message"&gt;Message&lt;/label&gt;
1837-
&lt;textarea id="message" name="message"&gt;&lt;/textarea&gt;
1838-
&lt;/p&gt;
1839-
&lt;input type="submit" value="SEND"&gt;
1840-
&lt;/form&gt;
1841-
&lt;/section&gt;
1842-
</code></pre>
1843-
<p>Your contact page and form should look similar to <a href="project/examples/exercise9-contact.html">Example 9</a>.</p>
1844-
<p>For more information about forms, <a href="framework/extras-form-controls.html">go here</a>.</p>
1845-
1846-
<div class="presenter-notes">
1847-
<p>Give an general overview of what each from control is used for as you are adding in the code. There's further resources available in the link provided in this slide.</p>
1848-
</div>
1849-
</section> -->
1850-
1851-
<section class="slide">
1852-
<h2>Center aligning with margin</h2>
1853-
<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 &amp; 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>
1854-
1855-
<textarea class="snippet" data-subject="#margin-auto">background-color: lightblue;
1856-
height: 100px;
1857-
width: 600px;
1858-
margin: 0 auto;</textarea>
1859-
<div id="margin-auto">box</div>
1860-
</section>
1861-
1862-
<section class="slide" data-markdown>
1863-
##Exercise #11 - Contact Form (continued)
1864-
1865-
In the markup for the form, a class of `contact-form` was included in the `form` tag to be used for styling since all the form elements are contained within it.
1866-
1867-
1. Set a width for the form and center align it on the page. Also add a background colour to see the text more clearly over the image.
1868-
1869-
```
1870-
.contact-form {
1871-
width: 600px;
1872-
margin: 10px auto;
1873-
background: white;
1874-
}
1875-
```
1801+
Ok, not quite done. Let's talk about some next steps.
1802+
</div>
1803+
1804+
<div class="slide" data-markdown>
1805+
##Next Steps & "Homework"
18761806

1877-
1. Add some padding to `contact-form` to keep the text from going right up to the edge. Also try adding the CSS property `border-radius` to add some rounded corners.
1878-
1879-
```
1880-
.contact-form {
1881-
width: 600px;
1882-
margin: 10px auto;
1883-
background: white;
1884-
padding: 20px;
1885-
border-radius: 4px;
1886-
}
1887-
```
1888-
1. To get the input and textarea to span all the way across the form, we can set the width to 100% so it takes up the entire width of the form. It's also possible to override the default border styles too. Add height to the textarea just to give more room for the user to type a message.
1889-
1890-
```
1891-
input,
1892-
textarea {
1893-
width: 100%;
1894-
border: 1px solid #ccc;
1895-
padding: 5px;
1896-
}
1897-
textarea {
1898-
height: 100px;
1899-
}
1900-
```
1901-
Your form should look similar to [example 11](project/examples/exercise11-contact.html).
1902-
1903-
There's so much more you can do with forms. Check out this project's final css file to see what other changes you can add or take a look at this resource: http://code.tiffbits.com/css3-form-styling-cheat-sheet/
1904-
</section>
1807+
Though we've covered a lot of material today, there are still lots of things to add to give your web page that extra personalization, finalize some styles and add some polish.
19051808

1809+
Here are some additional lessons you can try:
1810+
1811+
* [Sticky Footer]()
1812+
* [Contact page](framework/extras-form-styles.html) - adding background images & form styling
1813+
* [Forms, pt 2]() - how to submit a form
1814+
* [Home page: additional styles]() - this includes using icon fonts.
1815+
* [Add a favicon]()
1816+
</div>
1817+
19061818
<section class="slide" data-markdown>
19071819
##Getting ready Final Exercise #12
19081820

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Jane Smith | Contact Me</title>
6+
<link href='http://fonts.googleapis.com/css?family=Nixie+One|Open+Sans:300|Pacifico' rel='stylesheet' type='text/css'>
7+
<link rel="stylesheet" href="css/contact-page-styles.css">
8+
</head>
9+
<body class="contact">
10+
11+
<div class="page-wrap">
12+
<header>
13+
<h1><span class="highlight">Jane</span>Smith</h1>
14+
<h2>Web Developer + City Girl</h2>
15+
16+
<nav>
17+
<ul>
18+
<li><a href="#">Home</a></li>
19+
<li><a href="#">About</a></li>
20+
<li><a href="#">Contact</a></li>
21+
</ul>
22+
</nav>
23+
</header>
24+
25+
<section>
26+
<form class="contact-form" action="http://forms.brace.io/hello@your-email.com" method="POST">
27+
<h2>Let's meet for coffee!</h2>
28+
29+
<p>Send me a message at <a href="mailto:hello@your-email.com">hello@your-email.com</a>,
30+
use the form below or say "hi!" on one of my social networks.</p>
31+
<p>
32+
<label for="name">Name</label>
33+
<input id="name" type="text" name="name">
34+
</p>
35+
<p>
36+
<label for="email">Email</label>
37+
<input id="email" type="email" name="replyto">
38+
</p>
39+
<p>
40+
<label for="message">Message</label>
41+
<textarea id="message" name="message"></textarea>
42+
</p>
43+
<input type="submit" value="SEND">
44+
</form>
45+
</section>
46+
</div><!-- close .page-wrap -->
47+
48+
<footer>
49+
<p>&#169; 2014 by jane smith</p>
50+
</footer>
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)