Skip to content

Commit 90f3bd4

Browse files
committed
completed sp15 week3 programming
1 parent 0737ad2 commit 90f3bd4

File tree

11 files changed

+195
-22
lines changed

11 files changed

+195
-22
lines changed
56.8 KB
Loading
77.1 KB
Loading
-558 KB
Binary file not shown.
2.08 MB
Loading
Loading
Loading

sp15/wk3-programming/index.html

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<title>CanadaGram - Nicer than Instagram</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
<div class="container">
10+
<h1>CanadaGram!</h1>
11+
<h4>The nicest website on Earth</h4>
12+
<div class="button">Sign up!</div>
13+
<div class="image-container">
14+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
15+
</div>
16+
<div class="image-container">
17+
<img src="http://blog.jimdo.com/wp-content/uploads/2014/01/tree-247122.jpg">
18+
</div>
19+
<div class="image-container">
20+
<img src="http://www.freelive3dwallpapers.com/wp-content/uploads/2014/03/images-7.jpg">
21+
</div>
22+
<div class="image-container">
23+
<img src="https://www.deltahotels.com/var/delta/storage/images/hotels/delta-chelsea/local-attractions/entertainment/canada-s-wonderland/175997-3-eng-US/Canada-s-Wonderland_poi.jpg">
24+
</div>
25+
<div class="image-container">
26+
<img src="http://upload.wikimedia.org/wikipedia/commons/a/a2/Boulevard_Ren%C3%A9-L%C3%A9vesque_Est_Montr%C3%A9al_Canada.jpg">
27+
</div>
28+
<div class="image-container">
29+
<img src="http://media.digitalcameraworld.com/wp-content/uploads/sites/123/2013/03/norway_lofoten_haukland_01_DCW.jpg">
30+
</div>
31+
<div class="image-container">
32+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
33+
</div>
34+
<div class="image-container">
35+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
36+
</div>
37+
<div class="image-container">
38+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
39+
</div>
40+
</div>
41+
</body>
42+
</html>

sp15/wk3-programming/index2.html

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>CanadaGram - Nicer than Instagram</title>
5+
<link rel="stylesheet" href="style2.css">
6+
</head>
7+
8+
<body>
9+
<div class="container">
10+
<h1>CanadaGram!</h1>
11+
<h4>The nicest website on Earth</h4>
12+
<div class="button">Sign up!</div>
13+
<div class="image-container">
14+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
15+
</div>
16+
<div class="image-container">
17+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
18+
</div>
19+
<div class="image-container">
20+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
21+
</div>
22+
<div class="image-container">
23+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
24+
</div>
25+
<div class="image-container">
26+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
27+
</div>
28+
<div class="image-container">
29+
<img src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg">
30+
</div>
31+
</div>
32+
</body>
33+
34+
</html>

sp15/wk3-programming/instructions.html

+63-22
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<!-- REQUIRED TOOLS -->
3333
<div class="info-required">Required Tools: Google Chrome and a text editor</div>
3434
<!-- INTRODUCTION -->
35-
<div class="info-intro">In the spirit of Valentine's Day, you will be building a very basic webpage with HTML, CSS and images.</div>
35+
<div class="info-intro">Today, we'll be learning how to place, position, and space HTML elements. We'll explore different CSS styles, such as margin, padding, border, and position. You'll create a photo gallery similar to Instagram, but better: Canadagram.</div>
3636
</div>
3737
</div>
3838
<div class="body">
@@ -44,36 +44,77 @@
4444
<!-- Use UL LI Tags for each lists -->
4545
<!-- Use P Tags with "caption" class for paragraph captions (60% opacity) -->
4646
<!-- Use IMG Tags for assets/images -->
47-
<p>Time to put the HTML you learned to use! For this hands-on, we will be making a simple registration page for a dating site.</p>
48-
<img src="assets/images/handson.jpg">
49-
<p>At the end of this hands-on, you should have something like the page above.</p>
50-
<div class = "body-header">Step 1: Set Up HTML</div>
51-
<p>Every HTML file should have the following basic structure:
52-
<br>
47+
<p>At the end of this hands-on, you should have something like the page below.</p>
48+
<img src="assets/images/handson.png">
49+
<div class = "body-header"><br>Step 1: Set Up HTML</div>
50+
<p>We're going to write all the HTML elements with classes first, then style. Let's begin by making a "container" div inside &lt;body&gt;. Make sure you put all the other HTML tags inside this container. You'll see later on why we do this, but in a nutshell, container divs make it easy to move large blocks of HTML around the page.</p>
5351
<b>
54-
&lt;!DOCTYPE html&gt;
55-
<br>
56-
&lt;html&gt;
57-
<br>
58-
&lt;head&gt;
59-
<br>
60-
&lt;/head&gt;
61-
<br>
6252
&lt;body&gt;
6353
<br>
54+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class="container"&gt;
55+
<br>
56+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;
57+
<br>
6458
&lt;/body&gt;
6559
<br>
66-
&lt;/html&gt;
6760
</b>
6861
<br>
6962
</p>
70-
<div class = "body-header">Step 2: Add Content</div>
71-
<p>Start making your registration page by giving it a heading. Then, using <b>&lt;input&gt;</b> and <b>&lt;select&gt;</b> tags, provide the user with space to <em>type</em> their first name, and <em>choose</em> their gender, their gender preference, and their country using a dropdown menu. Put these options in a cohesive sentence like in the example page above. Lastly, make a "Submit" button using the <b>&lt;button&gt;</b> tag.</p>
72-
<div class = "body-header">Step 3: Image and Style</div>
73-
<p>Add an image before your text to spice this page up.
74-
<br>If you refresh your page, you'll likely see that your image is HUGE. Fix this by adding some CSS.<br>Create a new file and call it "style.css". Link to this file in your html using:<br><br><b>&lt;link rel="stylesheet" type="text/css" href="(path to style.css file)"&gt;</b><br><br>Put this inside the <b>&lt;head&gt;</b> tag of your HTML file. <br>Then, select the image and change its height to be around 300px.
63+
<p>Our website needs a title, description, and sign-up button! Using <b>&lt;h1&gt;</b> and <b>&lt;h4&gt;</b>, give your site a name and description. Also, make another div with the class "button". We'll style this later to look like a button. </p>
64+
<p>Your HTML should look something like this:</p>
65+
<img src="assets/images/example1.png">
66+
67+
<p>Next, let's create the HTML for the images. We'll make one image for now, then just copy and paste the code after we finalize the design.</p>
68+
69+
<p>Create a <b>&lt;div&gt;</b> with class "image-container", and inside "image-container", create an image tag. It's good practice to put your <b>&lt;img&gt;</b> inside <b>&lt;div&gt;</b>. Use any image you like.</p>
70+
71+
<p>Updated code screenshot!</p>
72+
<img src="assets/images/example2.png">
73+
74+
<div class = "body-header"><br>Step 2: Make it Pretty</div>
7575
<br>
76-
</p>
76+
<img src="assets/images/screenshot2.png">
77+
<p>Canadagram looks a bit ugly now - but don't worry! With a bit of CSS, we can easily make it pretty.</p>
78+
<p>Give your entire website a font facelift by using targeting body in your CSS. Additionally, let's style .container accordingly:</p>
79+
.container {
80+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background: #eee;
81+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text-align: center;
82+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 700px;
83+
<br>}
84+
85+
<p>Refresh the page and you'll see a gray box with the title centered. The photo is still too big, so let's fix that. We can select all <b>&lt;img&gt;</b> tags and style:</p>
86+
img {
87+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: 200px;
88+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 200px;
89+
<br>}
90+
91+
<p>Oh no - The images are distorted! That's because you're manually setting the width <em>and</em> the height of the image. The image will be resized to fit your dimensions, causing it to warp. Usually, you'll only want to set either the height <em>or</em> the width - not both. But in this case, we want our images to be square. How can we fix that? <b>Use this nifty style: object-fit: cover</b></p>
92+
img {
93+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: 200px;
94+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 200px;
95+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;object-fit: cover;
96+
<br>}
97+
98+
<p>You can read more about this nifty trick <a href="https://medium.com/@chrisnager/center-and-crop-images-with-a-single-line-of-css-ad140d5b4a87">here</a>. Basically, object-fit: cover centers the photo within the 200 by 200px square, and <em>automatically crops</em> any part of the image that falls outside of the square - without distortion.</p>
99+
100+
<div class = "body-header"><br>Step 3: Positioning and Spacing</div>
101+
<p>Let's copy and paste the .image-container divs to add a few more photos on the page. These are <b>&lt;div&gt;</b> tags, so recall that they stack <em>vertically</em>.</p>
102+
<br><img src="assets/images/screenshot3.png">
103+
<p>Fix this by adding <b>display: inline-block</b> to <b>.image-container</b>. The images are pretty close together, so let's give them some margin. Add <b>margin: 10px</b> to <b>.image-container</b>. This adds a 10px margin to every side of each <b>&lt;div&gt;</b> with the tag .image-container. Finally, add <b>border: 5px solid white</b>.</p>
104+
<p>Notice that the edge of the gray box is very close to the text and images. Instead of fiddling with the width and possibly messing up the layout, let's just use <b>padding</b> to "push" the edge of the box out. Add <b>padding: 30px</b> to <b>.container</b>. This adds 30px of space along the inner edge of your gray .container.</p>
105+
106+
<div class = "body-header"><br>Step 4: Final Touches</div>
107+
<p>Your website looks pretty nice! (I hope). However, the content isn't centered. To fix that, add <b>margin: auto</b> to <b>.container</b>. Now you see why we put everything inside <b>.container</b> - it makes it easy to move all the elements, including centering them!</p>
108+
<p>Finally, let's make the button pretty. Add the following styling to <b>.button</b>:</p>
109+
.button {
110+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background: #517fa4;
111+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color: white;
112+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin: 20px auto;
113+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding: 10px 15px;
114+
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 200px;
115+
<br>}
116+
<p>Play around in web inspector to see what each one of these styles do, and try making your own button.</p>
117+
77118
</div>
78119
</div>
79120
</div>

sp15/wk3-programming/style.css

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
body {
2+
font-family: Arial;
3+
}
4+
5+
.container {
6+
background: #eee;
7+
margin: auto;
8+
padding: 30px;
9+
text-align: center;
10+
width: 700px;
11+
}
12+
13+
.button {
14+
background: #517fa4;
15+
color: white;
16+
margin: 20px auto;
17+
padding: 10px 15px;
18+
width: 200px;
19+
}
20+
21+
.image-container {
22+
border: 5px solid white;
23+
display: inline-block;
24+
margin: 10px;
25+
}
26+
27+
img {
28+
height: 200px;
29+
width: 200px;
30+
31+
object-fit: cover;
32+
}

sp15/wk3-programming/style2.css

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
body {
2+
font-family: Arial;
3+
}
4+
5+
.container {
6+
background: #eee;
7+
margin: auto;
8+
padding: 30px;
9+
text-align: center;
10+
width: 700px;
11+
}
12+
13+
img {
14+
height: 200px;
15+
width: 200px;
16+
17+
object-fit: cover;
18+
}
19+
20+
.image-container {
21+
border: 5px solid white;
22+
display: inline-block;
23+
margin: 10px;
24+
}

0 commit comments

Comments
 (0)