Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

37
Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1 http://fa10.decal.aw- industries.com

description

Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1. http://fa10.decal.aw-industries.com. Announcements. Mini-Project 1 due Tonight before 11:59pm Linking to a neighbors’ sites Any questions ? Submission (.txt file and upload to FTP) Enrollment should be Finalized - PowerPoint PPT Presentation

Transcript of Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Page 1: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Quiz #3 - CSSLecture Code: 544698

Get Neighbors’ URLs for MP1http://fa10.decal.aw-industries.com

Page 2: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Announcements Mini-Project 1 due Tonight before 11:59pm

Linking to a neighbors’ sites Any questions? Submission (.txt file and upload to FTP)

Enrollment should be Finalized

Previous lecture slides had some small typos in closing tags Missing / in </tag> Corrected

Spring 2010 material as reference http://sp10.decal.aw-industries.com

Need help? Office hours by request Email, after class

Page 3: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Today’s Agenda CSS Properties: Margin, Padding, Border, and CSS Selector: a:hover

Where are we in the material?

Building a Web 2.0 Website

Layouts

HTML Element: <div></div>

From Mockup to HTML and CSS

CSS Properties: Width, Height, Position

Worksheet

Lab

Page 4: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

CSS Property: borderExample:

div { border: 1px solid #000000; }div { border-top: 1px solid #000000; border-right: 1px solid

#000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; }

Common Values:Border width: 1pxBorder style: solid

Border color: #000000

1. p { border: 3px solid #000000; }2. p { border: 3px dashed #000000; }3. p { border: 3px dotted #000000; }

• solid• dotted• dashed• double• groove• ridge

• inset• outset

1.

2.

3.

Page 5: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Margins and Padding?<!DOCTYPE html><head>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /></head><body>

<p>Paragraph One</p><p id=“two”>Paragraph Two</p>

</body></html>

p{ background-color: red; }p#two{ background-color: blue; }

p{ background-color: red; margin: 0; }p#two{ background-color: blue; }

Page 6: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

CSS Properties: margin, paddingMargin: space between this object and others

Padding: space between the object’s border and contents

Example: div { margin: 5px 10px; } div { margin: 5px 10px 5px 10px; }

Order: top, right, bottom, left

div { margin-top: 5px; margin-bottom: 5px; margin-left: 10px; margin-right: 10px; } Padding has same syntax

Common Values: Pixels: 10px

Div_1

Div_2

margin

padding

Page 7: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

CSS Selector: a:hover

a { }Selects all links on the page.

CSS Selectors

a:hover {background-color: …color: …

}

Style affected by a:hover in CSS

Tooltip affected by <a title=“…” > in HTML

a:hover {}Also selects all links on the page but specifies a set of styles only for the hover state.

Page 8: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Material So Far…HTML and CSS

Purpose and CapabilitiesSyntaxTags / PropertiesHow to Use

Built a HTML5 standards compliant website (by tonight)

Q: Are we done?

Page 9: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

What’s to Come… Dissect existing sites and

mockups into HTML and CSS components

Use background images to spice up our websites

Use CSS positioning to create modular and non-linear layouts

A: Not yet…

…of course Javascript, PHP, and MySQLStill to come

http://www.jwhanif.net/

Page 10: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

That’s More Like It…

http://cssremix.com

Page 11: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Building a Web 2.0 Website

1. Inspiration2. Choose a Layout Style3. Photoshop Mockup4. Slicing and Dicing Mockup (HTML & CSS)

Page 12: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Choose a Layout

Q: What do we mean by “layout”?

Q: How many different types of layouts are there?

Q: What makes a good layout?

Q: How do we go about building our layout?

Layouts?... o_0

A: The placement and interaction of your site’s components.

A: Infinitely many… but some are more common and better than others.

A: Think about: consistency, ease of use, form following function. Then iterate.

A: Stay tuned…

Page 13: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Componentsmenu

slideshow / images

heading

images

header

maincontent

footer

navigation

sub-content

Page 14: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Differing Layouts

http://www.vreplay.com/

Page 15: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

http://inspiredology.com/

Page 16: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

http://www.richbrown.info/

Page 17: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

http://crushlovely.com/

Page 18: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Skip Photoshop for Now

Insert “How to create a website mockup in Photoshop” here.

Page 19: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Step-by-StepFrom Mockup to HTML and CSS

1. Identify your site’s different components.

2. Create a <div> that corresponds to each component. (Outside -> Inside, Top -> Bottom, Left -> Right)

3. Working from the outside in, translate each component into HTML. (Outside -> Inside, Top -> Bottom, Left -> Right)

4. Apply CSS.

<div id=“page”></div>

<div id=“page”><div id=“menu”></div><div id=“content”></div>

</div>

<div id=“page”><div id=“menu”>

<ul><li><a></a></li>

</ul></div><div id=“content”></div>

</div>

Page 20: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

<div> Element<div>’s are our general layout building blocks/containers

Used to logically group HTML elementsSeparate regions of code into functional regions“these HTML elements make up the menu system”

Like span’s they typically have no visual effect on our HTML documents by themselvesspan’s are inline elementsdiv’s are block elements

What happens when we wrap a set of elements in div tags?

Page 21: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

div Element …continued

<h3>Menu</h3><a></a><a></a><a></a><a></a><a></a><a>print story</a><h1>News Story</h1><p>

<a></a></p>

<div id=“menu”><h3>Menu</h3><a></a><a></a><a></a><a></a><a></a>

</div>

<div id=“newsStory”><a>print story</a><h1>News

Story</h1><p>

<a></a></p>

</div>

Page 22: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Mockup -> HTML & CSS Example

1. Identify Components

http://cargocollective.com/

Page 23: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Mockup -> HTML & CSS Example

2. Corresponding <div>’s(Outside -> Inside, Top -> Bottom, Left -> Right)

http://cargocollective.com/

…<body> <div> <div id=“sidebar”> <div id=“menu”></div> <div id=“search”></div> </div> <div id=“content”> <div id=“header”></div> <div id=“entries”></div> </div> </div></body>…

<div> <div id=“sidebar”> <div id=“menu”></div> <div id=“search”></div> </div> <div id=“content”> <div id=“header”></div> <div id=“entries”></div> </div> </div>

Page 24: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Mockup -> HTML & CSS Example

3. Translate Each Component(Outside -> Inside, Top -> Bottom, Left -> Right)

http://cargocollective.com/

…<div id=“sidebar”>

<div id=“menu”><ul>

<li><a href=“…”>In your network</a></li><li><a href=“…”>Featured websites</a></li><li><a href=“…”>Featured projects</a></li>

</ul></div><div id=“search”>

<form action=“…”><p><input type=“text” /><input type=“submit”

value=“search”/></p><p><input id=“prj” type=“radio” /><label

for=“prj”>Projects</label><input id=“ppl” type=“radio” /><label for=“ppl”>People</label</p>

</form></div>

</div>…

<ul><li><a href=“…”>In your network</a></li><li><a href=“…”>Featured websites</a></li><li><a href=“…”>Featured projects</a></li>

</ul>

Page 25: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Mockup -> HTML & CSS Example

HTML Completed

embargo.zip > index.html

Page 26: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Mockup -> HTML & CSS Example

Oops… Layout Totally Wrong?

Nothing more CSS can’t fix

Q: What happened?

A: <div>’s are block leveland naturally appearon their own line

Page 27: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

CSS Properties: height, widthCan only be set on block level elements and a few inline

elements such as <img />

Example:div { width: 100px; height: 100px; }div { width: 100%; height: 100%; }

Common Values:Pixels: 20pxPercentage of parent: 100%Not set/auto: width of contents

heig

ht: 1

00px

;

width: 100px;

Page 28: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

heig

ht: 1

00px

;

width: 100px;

CSS Properties: height, width …continued

heig

ht: 1

00px

;

width: 100px;

heig

ht: 1

00%

;

width: 100%;

width: 100%;

heig

ht: 1

00%

;

heig

ht: a

uto;

width: auto;

width: 100px;

heig

ht: 1

00px

;

Page 29: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

CSS Properties: position Example:

div { position: absolute; }

Common Values: absolute

Relative to closest parent who has its position set. If no parent qualifies, relative to document boundaries.

Removes object from flow of document. Object takes up no space.

relative Relative to the objects natural location.

fixed Relative to browser window’s boundaries. Removes object from flow of document. Object takes up no space.

static Don’t typically use this because it is already the default behavior.

Page 30: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

CSS Properties:top/bottom, left/right

Used in conjunction with position

Example:div { position: absolute; top: 0px; left: 0px; }

Common Values:Pixels: 10px

Page 31: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

position Document Flow<span>A</span><div>B</div><span>C</span>

code:

div { position: static; } div { position: relative; } div { position: absolute; }

span: “A”

div: “B”

span: “C”

span: “A”

div: “B”

span: “C”

span: “A”

div: “B”

span: “C”

ordiv { position: fixed; }

Page 32: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

top & left Effectsdiv {

position: static;top: 10px;left: 10px;

}

span: “A”

div: “B”

span: “C”

span: “A”

div: “B”

span: “C”

span: “A”

div: “B”

span: “C”

div {position: relative;top: 10px;left: 10px;

}

div {position: absolute;top: 10px;left: 10px;

}

div: “B”

div: “B”

top: 0px; left: 0px; top: 0px; left: 0px;

top: 0px; left: 0px;

10px

10px

10px

10px

Page 33: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

absolute References

top: 0px; left: 0px;

ABtop: 0px; left: 0px;

AB

<div id=“A”><div id=“B”></div></div>code:

div {position: absolute; top: 10px; left: 10px;

}

div { position: absolute; }#A { top: 10px; left: 10px; }#B { bottom: 10px; right: 10px; }

Page 34: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

absolute vs. fixed

Please see included absolute_vs_fixed.html file for demo

Page 35: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Positioning Worksheet

positioning worksheet.pdf

Page 36: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

How Do We Fix This?

#sidebar {position: fixed;top: 0;left: 0;height: 100%;width: 200px;

}#content {

position: absolute;top: 0;left: 200px;height: 100%;width: 800px;

}

Page 37: Quiz #3 - CSS Lecture Code: 544698 Get Neighbors’ URLs for MP1

Quiz #3 - CSSLecture Code: 544698

Then… Labhttp://fa10.decal.aw-industries.com