client-side web development - github pages · the css transform property lets you modify the...

59
Client-Side Web Development Class 5.1

Upload: others

Post on 26-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Client-Side Web DevelopmentClass 5.1

Page 2: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Today’s Topics

• CSS Transition

• CSS Transform

• Exercise: Pseudo Judo

Page 3: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Announcements

Page 4: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Schedule Change

Page 5: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Work Period

Page 6: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Recording

Page 7: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

CSS Zen Garden

Page 8: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Any Questions?

Page 9: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Pseudo-Classes

Page 10: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

A pseudo-class is a keyword added to a selector that specifies a special state of the

selected element.

Page 11: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

A pseudo-class will inherit the CSS property of the elements normal state

Page 12: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

There are many different pseudo-classes

Page 13: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Different elements can have different pseudo-classes

Page 14: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

/* any element */ div:hover { border: 3px solid red; }

/* buttons and links */ button:active { border: 1px inset black; }

/* inputs */ input:invalid { background-color: red; }

/* checkboxes and radio buttons*/ input[type="checkbox"]:checked { background-color: green; }

Page 15: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

CSS Transition

Page 16: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

CSS Transitions provide a way to control the speed in which CSS

property changes.

Page 17: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Instead of having property change take effect immediately, you can

cause the change to take place over a period of time.

Page 18: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

There are 4 CSS Transition properties

Page 19: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

// Defaults of transition properties .button { transition-property: all;   transition-duration: 0s;   transition-timing-function: ease;   transition-delay: 0s; }

// Shorthand .button { transition: all 0s ease 0s; }

Page 20: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

transition-property

Page 21: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

This property set which CSS properties will be transitioned. The

default is all.

Page 22: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Using all will affect every transitional property the same

Page 23: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

It is possible to transition properties of an element different by using a

comma to separate each transition

Page 24: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

// Affects all properties .button { transition: all 1s ease 0s; }

// Does NOT work! .button { transition: color 1s; transition: width 2s; }

// Proper Way .button { transition: color 1s, width 2s; }

Page 25: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Not All CSS properties are animatable.

Page 26: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

transition-duration

Page 27: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Sets how long a property will take to transition from one state to the

next. The default is 0s.

Page 28: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The transition-duration value can be in seconds (s) or

microseconds (ms)

Page 29: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

transition-delay

Page 30: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Sets how long to wait before the transition should start. The default

is 0s.

Page 31: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The transition-delay value can be in seconds (s) or microseconds (ms)

Page 32: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

When using the shorthand, the first time value will alway be duration

and the second delay.

Page 33: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

transition-timing-function

Page 34: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Sets the speed curve of the transition.

Page 35: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

There are several predefined timing-function values.

Page 36: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Timing Function Values

• ease (default)

• ease-in

• ease-out

• ease-in-out

• linear

• step-start

• step-end

Page 37: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Timing Function Functions

• steps()

• cubic-bezier()

• frames()

Page 38: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Examples

Page 39: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

CSS Transform

Page 40: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The CSS Transform property lets you modify the coordinate space of

the CSS visual formatting model.

Page 41: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

With CSS Transform, elements can be translated, rotated, scaled, and

skewed.

Page 42: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

translate()

Page 43: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The translate() function moves an element in a

X and Y direction

Page 44: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

// moves up and to the right .box { transform: translate(30px, -30px) }

// moves down and to the left .box { transform: translate(-30px, 30px) }

// does not move .box { transform: translate(0px, 0px) }

Page 45: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

scale()

Page 46: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The scale() function will increase or decrease the size of the element

by multiple provided

Page 47: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Using the scale() function on an element does NOT affect adjacent

elements

Page 48: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

// Increase the size in both directions .box { transform: scale(3) }

// Increase 2 in X direction .box { transform: scale(2,0) }

// Decrease the size .box { transform: scale(0.5) }

Page 49: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

rotate()

Page 50: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The rotate() will rotate an element by the given angle on the

Z-axis

Page 51: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Use rotateX() or rotateY() to rotate an element on the X and Y axis, respectively

Page 52: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The angle value takes deg or turn units

Page 53: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

/* Rotate clockwise half way around */ .box { transform: rotate(180deg) }

/* Rotate counter-clockwise all around */ .box { transform: rotate(-360deg) }

/* Rotate clockwise 3 times around */ .box { transform: rotate(3turn) }

/* Flips on X axis */ .box { transform: rotateX(3turn) }

/* Spins on Y axis */ .box { transform: rotateY(3turn) }

Page 54: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

skew()

Page 55: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The skew() function skews the element in X and Y direction by the

provide angle

Page 56: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

The value must be deg units

Page 57: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Examples

Page 58: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

Exercise: Pseudo Judo

Page 59: Client-Side Web Development - GitHub Pages · The CSS Transform property lets you modify the coordinate space of the CSS visual formatting model. With CSS Transform, elements can

For next class...

• Project: CSS Zen Garden

Next Week...

• CSS Animation

• Animation Techniques & Best Practices