today’s objectives assignment 1 padding, margins, borders fluid layout page building...

32
Today’s objectives Assignment 1 Padding, Margins, Borders Fluid Layout page Building accessible Table Element size with padding and border Sprites

Upload: myron-park

Post on 30-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Today’s objectives

Assignment 1 Padding, Margins, Borders Fluid Layout page Building accessible Table Element size with padding and

border Sprites

Page 2: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

ASSIGNMENT 1 NOTES

Page 3: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Tables commonly used for page layout – not recommended

Proper use of table<table></table> should be used for tabular data

Page 4: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Tables commonly used for page layout – not recommended

Should not uses tables for layout.

Page 5: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

<!doctype html><html><head><meta charset="utf-8"><title>Document structure</title></head>

<body></body></html>

BASIC DOCUMENT STRUCTURE

Page 6: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

<html>

<head> <body>

<title> <p><h1>

<strong>

BASIC DOCUMENT STRUCTURE

Page 7: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

<!doctype html><html><head><meta charset="utf-8"><title>Document structure</title>

</head>

<body>

<header id="main-header"> <h1>Mount Olympus News</h1></header>

</body></html>

<style type="text/css">body, ul, li { margin:0; padding:0;}</style

HTML goes here

CSS goes here

BASIC DOCUMENT STRUCTURE

Page 8: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

<!doctype html><html><head><meta charset="utf-8"><title>Document structure</title>

</head>

<body><h2>Prometheus Heats Things Up</h2>

</body></html>

<style type="text/css">body, ul, li { margin:0; padding:0;}</style><header id="main-header"> <h1>Mount Olympus News</h1></header>

HTML does not go here

Page 9: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

SECTION element A general rule - SECTION appropriate if

element's contents listed in the doc outline.

It’s a chunk of related content

Page 10: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

<section>

</section>

<section>

</section>

Main news itemsOpinion items

Page 11: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

<section id=“IXD”>

</section>

<section id=“install”>

</section>

Section by content.

Page 12: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

PADDING, MARGINS, ANDBORDERS

CSS

Page 13: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders Web browsers treat all html elements as

boxes.

A tag is a box with content inside (text, graphic or other html element).

Page 14: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders

HELLO WORLD!

TOP PADDING

RIGHT PADDING

LEFT PADDING

BOTTOM PADDING

TOP MARGIN

BOTTOM MARGIN

LEF

T M

AR

GIN

RIG

HT

MA

RG

IN

RIG

HT

BO

RD

ER

LEF

T B

OR

DE

R

TOP BORDER

BOTTOM BORDER

Other Element

Other Element

Oth

er E

lem

ent

Oth

er E

lem

ent

Page 15: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders Padding: space between the content and

the content’s border. Separates content from its border.

HELLO WORLD!

TOP BORDER

PADDING

PADDING

PA

DD

ING

PA

DD

ING

Page 16: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders Border: line drawn around each edge of

the box. Can be four sides, on any single side, or

any combination of sides.

HELLO WORLD!

Page 17: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBordersBorder style values: none: Defines no border dotted: Defines a dotted border dashed: Defines a dashed border solid: Defines a solid border double: Defines two borders. groove: Defines a 3D grooved border. ridge: Defines a 3D ridged border. inset: Defines a 3D inset border. outset: Defines a 3D outset border.

HELLO WORL

D!

Page 18: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders Background-color: fills space inside

border, including padding area. Margin separates one element from

another.

Hello How are you?

Padding Padding

Margin

Margin

Page 19: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Margins

HELLO WORLD!

TOP MARGIN

LE

FT

MA

RG

IN

RIG

HT

MA

RG

IN

Other Element

Other Element

Oth

er E

lem

ent

Oth

er E

lem

ent

BOTTOM MARGIN

Page 20: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders Padding adds space between the

content, and the border and keeps the content from appearing cramped inside the box.

Margins add white space (gutter) between elements giving the overall look of the page a lighter appearance.

Page 21: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders Four properties control padding: padding-top,

padding-right, padding-bottom, and padding-left. Four properties control margin edges: margin-

top, margin-right, margin-bottom, and margin-left.

margin-top : 5px;margin-right : 5px;margin-bottom : 5px;margin-left : 5px;

padding-top : 5px;padding-right : 5px;padding-bottom : 5px;padding-left : 5px;

padding: 10px 5px 5px 10px;margin: 0 10px 10px 20px;

Page 22: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders

margin-top : 5px;margin-right : 5px;margin-bottom : 5px;margin-left : 5px;

padding-top : 5px;padding-right : 5px;padding-bottom : 5px;padding-left : 5px;

padding: 10px 5px 5px 10px;margin: 0 10px 10px 20px;

The order of the four values is: top, right, bottom, and left.

TRouBLe - Top, Right, Bottom, and Left.

Shortcut

Page 23: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders When value is 0, don’t need

measurement unit (e.g., em, px).

Use margin: 0; instead of margin: 0px;.

When same value for all four sides, use a single value margin: 5px;

Page 24: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Padding, Margins, andBorders When same value for both top and

bottom and another value for left and right, use two values:

margin : 0 2em; Sets top and bottom margins to 0 ; left

and right margins to 2ems.

Page 25: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Collapsing margins - two marginsactually become one. Bottom margin of unordered list = 30 pixels. Top margin of a following paragraph = 20

pixels.

You think: 30px + 20px = 50px spacing

BUT browser uses the largest margin (30px)

You can use padding to get around this issue.

Page 26: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Collapsing margins - two marginsactually become one. Browser does NOT add two vertical

margins values but applies larger of the two margins. •Item1

•Item2•Items 3 – margin bottom 30px

Paragraph – margin top 20 px

30px not 50px

Page 27: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Block boxes and inline boxes Although web browsers treat every tag

as a kind of box, not all boxes are alike. Block boxes and inline boxes—that

correspond to the two types of tags—block-level and inline tags.

Page 28: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Block boxes and inline boxes A block-level tag creates a break

before and after it. <p> <h>,<div>, <section> <ul>, <ol>, etc.

Inline tags don’t create a break before or after them.<span>, <em>, <strong>, <a>

Page 29: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Block and inline elements

Top or bottom margins and padding do NOT increased or decrease height of inline elements.

Must use display : block;em {padding-top: 20px;padding-bottom: 20px;display: block;

}

Page 30: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Block and inline elements

Make a block-level element act like an inline element: display: inline;

ul li {

display: inline;}

This is useful for setting navigation items

Home AboutProduc

ts

Home

AboutProduc

ts

Page 31: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Block and inline elements

Top or bottom margins and padding do NOT increased or decrease height of inline elements.

Must use display : block;ul li a {display: inline;

}

Home AboutProduc

ts

Page 32: Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border

Block and inline elements

Top or bottom margins and padding do NOT increased or decrease height of inline elements.

Must use display : block;ul li a {display: inline-block;

}

Home About Products