+ All Categories
Home > Documents > HTML5 and CSS3

HTML5 and CSS3

Date post: 22-Feb-2016
Category:
Upload: ohio
View: 53 times
Download: 0 times
Share this document with a friend
Description:
Neal Stublen [email protected]. HTML5 and CSS3. Chapter 8 CSS3 Transforms and Transitions. Transforms. Transforms. Defined by the transform property Translate Rotate Scale Skew Apply to any element without affecting document flow - PowerPoint PPT Presentation
Popular Tags:
27
HTML5 AND CSS3 Neal Stublen [email protected]
Transcript
Page 1: HTML5 and CSS3

HTML5 AND CSS3Neal Stublen

[email protected]

Page 2: HTML5 and CSS3

CHAPTER 8

CSS3 TRANSFORMS AND TRANSITIONS

Page 3: HTML5 and CSS3

Transforms

Page 4: HTML5 and CSS3

Transforms Defined by the transform property

TranslateRotateScaleSkew

Apply to any element without affecting document flow

Elements occupy their original size and location for document flow

Page 5: HTML5 and CSS3

The translate property Move elements left, right, up, down Similar to position: relative but

without flow implications

transform: translate(x, y);-webkit (display: inline-block)-moz-ms-o

Page 6: HTML5 and CSS3

The scale property Resize elements – larger or smaller Scale of 1.25 = 25% larger

transform: scale(x, y);-webkit (display: inline-block)-moz-ms-o

Page 7: HTML5 and CSS3

The rotate property Rotate elements 0 to 360 degrees

transform: rotate(angle);-webkit (display: inline-block)-moz-ms-o

Page 8: HTML5 and CSS3

The skew property Skew elements in the x and y directions 0 to 360 degrees

transform: skew(x, y);-webkit (display: inline-block)-moz-ms-o

Page 9: HTML5 and CSS3

The origin property Redefine the origin for a transform

transform-origin: x y;-webkit (display: inline-block)-moz-o

Page 10: HTML5 and CSS3

Apply Multiple Transforms Applying multiple transforms can be

done with a single line of CSS

transform: translate(x, y) scale(x, y) …;

Page 11: HTML5 and CSS3

Apply transforms to an ad Update the “Put up your dukes” ad to

transform the element on :hover.

Find the element in the HTML Update h1:hover

Rotate, translate, scaleOrigin?

Page 12: HTML5 and CSS3

Transitions

Page 13: HTML5 and CSS3

Transitions Animate form elements Apply a transformation over time instead

of immediately No JavaScript required

Page 14: HTML5 and CSS3

What can we animate? Color (color, background-color) Position (left, top, right, bottom) Spacing (line-height, padding, margin) Size (width, height) Shadow (text-shadow) Transparency (opacity) Transformation (transform)

Page 15: HTML5 and CSS3

Create a transition Specify the properties to be transitioned

on :hover

transition-property: background-color;-webkit-moz-o

Include prefix on property as well when needed

Page 16: HTML5 and CSS3

How long? We need to specify the duration of the

transition Durations are specified in seconds (s) or

milliseconds (ms)

transition-duration: 0.5s;transition-duration: 500ms;

Required before you can see anything

Page 17: HTML5 and CSS3

Not smooth enough? Use transition timing to control the

animation

transition-timing-function: function;

Available functions:ease, linear, ease-in, ease-out, ease-in-out

Page 18: HTML5 and CSS3

When should it start? Control the start of the animation by

adding a delay Times specified in seconds (s) or

milliseconds (ms)

transition-delay: 0.1stransition-delay: 100ms

Delays can be negative

Page 19: HTML5 and CSS3

Putting it all together A shorthand syntax allows everything to

be specified together

transition: property duration function delay

Page 20: HTML5 and CSS3

Not enough? Specify multiple transitions with commas

transition-property: transform, color;transition-delay: 0.2s, 0.1s;transition-timing-function: ease-out;

Similar for shorthand syntax

Page 21: HTML5 and CSS3

Apply transforms to an ad Update the “Put up your dukes” ad to

transition the element on :hover.

Find the element in the HTML Update h1 to transition the

color and transform

Page 22: HTML5 and CSS3

Animations

Page 23: HTML5 and CSS3

Keyframes Allows control of intermediate states not

available through transitions

Create a named animation Attach the animation to an element

Page 24: HTML5 and CSS3

Create an animation Use the @keyframes rule

@-webkit-keyframes ‘name’ { 0% { opacity: 0 } 20% { opacity: 0.5; } 100% { opacity: 1; }}

Page 25: HTML5 and CSS3

Attach to an element CSS properties attach an animation to an element

-webkit-animation-name-webkit-animation-duration-webkit-animation-timing-function-webkit-animation-iteration-count-webkit-animation-direction: alternate-webkit-animation-delay-webkit-animation-fill-mode (stopped state)-webkit-animation-play-state (.js control)

Page 26: HTML5 and CSS3

Animation shorthand Specify the animation in a single line

-webkit-animation: name duration timing-function iteration direction fill-mode

Page 27: HTML5 and CSS3

Animation Sample View a color animation

http://www.w3schools.com/css/css3_animations.asp

Add a rotation on :hover


Recommended