Slide 1

Slide 1 text

Intro to CSS Animations with Victor Lourng

Slide 2

Slide 2 text

Hi, I’m Victor. •I make websites for a living. •Yes, I’m in high school.

Slide 3

Slide 3 text

What is an animation? •A change from one style to another.

Slide 4

Slide 4 text

What is an animation? •A change from one style to another. • Properties • Transitions • Keyframes

Slide 5

Slide 5 text

Properties •Attributes of an element being changed Color

Slide 6

Slide 6 text

Properties •Attributes of an element being changed Color

Slide 7

Slide 7 text

Properties •Attributes of an element being changed Color Shape

Slide 8

Slide 8 text

Properties •Attributes of an element being changed Color Shape

Slide 9

Slide 9 text

Properties •Attributes of an element being changed Position Color Shape

Slide 10

Slide 10 text

Properties •Attributes of an element being changed Position Color Shape

Slide 11

Slide 11 text

Properties •Attributes of an element being changed • Size • Rotation • Opacity • (and so on)

Slide 12

Slide 12 text

Transition •How the properties will animate • http://codepen.io/LabLayers/pen/MwzgNB •Full list: • http://easings.net/ •Why is this important? • Cars • Tennis balls

Slide 13

Slide 13 text

Keyframes •Steps of attributes (and sometime transitions) • At 0%, move down • At 25%, move right • At 50%, move up • At 75%, move left

Slide 14

Slide 14 text

Keyframes •Steps of attributes (and sometime transitions) • At 0%, move down and turn green • At 25%, move right and turn blue • At 50%, move up and turn purple • At 75%, move left and turn red

Slide 15

Slide 15 text

What is an animation? •A change from one style to another. • Properties • Attributes of an element being changed • Transitions • How the properties will animate • Keyframes • Steps of attributes (and sometime transitions)

Slide 16

Slide 16 text

Put it together and you’ll get…

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Animating Elements in CSS •It’s not that hard (really!)

Slide 19

Slide 19 text

Animating Elements in CSS •It’s not that hard (really!) • Properties • Attributes of an element being changed • Transitions • How the properties will animate • Keyframes • Steps of attributes

Slide 20

Slide 20 text

Translation into CSS •It’s not that hard (really!) • Properties • Standard CSS properties like color: red • Transitions • transition: all 500ms linear; • Keyframes & Animations • @keyframes myAnimation { } • animation: myAnimation;

Slide 21

Slide 21 text

CSS Transition Syntax transition: color 200ms linear 500ms; transition-property: color; transition-duration: 200s; (transition-timing-function: linear;) (transition-delay: 500ms;)

Slide 22

Slide 22 text

CSS Transitions •It’s simple. .button { background: purple; color: white; } .button:hover { transition: 300ms all ease; background: white; color: purple; }

Slide 23

Slide 23 text

CodePen Follow-Along • Start here: • http://tiny.cc/csstransitions • End result: • http://tiny.cc/csstransitions2 • Click the icon in the bottom right hand corner to toggle display mode

Slide 24

Slide 24 text

CSS Keyframe Syntax .circle { animation: my-animation 5s; } @keyframes my-animation { 0% {background: red;} 50% {background: blue;} 100% {background: green;} }

Slide 25

Slide 25 text

CSS Animation Syntax animation: my-animation 5s linear 0s infinite alternate running; animation-name: my-animation; animation-duration: 5s; (animation-timing-function: linear;) (animation-delay: 0s;) (animation-iteration-count: infinite;) (animation-direction: alternate;) (animation-play-state: running;)

Slide 26

Slide 26 text

CodePen Follow-Along • Start here: • http://tiny.cc/csskeyframes • End result: • http://tiny.cc/csskeyframes2

Slide 27

Slide 27 text

Chrome Developer Tools • Great for debugging Javascript & CSS • Right an element with an animation and select Inspect Element • On the right Styles pane, you can slow all animations or change the curve

Slide 28

Slide 28 text

Cool Examples • http://codepen.io/bennettfeely/pen/ErFGv • http://cssdeck.com/labs/felix-the-magic-bag-animation • http://www.species-in-pieces.com/ • http://bennettfeely.com/csscreatures/ • http://www.sanrio.com/timeline

Slide 29

Slide 29 text

Where I Use CSS Animations • http://brainitch.com/ers/ • http://booksmart.it/ • https://everfreenw.com/archive/2015/everfree-northwest- 2015/index.html • https://chrome.google.com/webstore/detail/harlem-shake- the-web/ldejkceiibdbkgjfiagpjhjdadgkelib?hl=en Advice for Beginners • https://www.youtube.com/watch?v=E1oZhEIrer4

Slide 30

Slide 30 text

Thank you!