SlideShare a Scribd company logo
1 of 26
18
TRANSITIONS, TRANSFORMS,
AND ANIMATION
OVERVIEW
• Creating smooth transitions
• Moving, rotating, and scaling elements
• Combining transitions and transforms
• 3-D transforms
• Keyframe animation overview
CSS Transitions
• CSS transitions create a smooth
change from one state to another.
• They fill in the frames in between
(tweening).
• Example: Gradually changing a
button from red to blue (through
purple) when the mouse pointer
hovers over it.
State 1: Default
State 2: When the mouse is over
the element
Transition Properties
transition-property
Which CSS property to change
transition-duration
How long the transition should take in seconds (or milliseconds)
transition-timing-function
The manner in which the transition accelerates
transition-delay
Whether there should be a pause before the transition starts and
how long that pause should be (in seconds)
Specifying the Property
transition-property
Values: Property-name, all, none
Identifies the property that will receive a transition when it changes
state.
Here, we want to smooth out the change in background color when
the color changes from hovering or focus:
.smooth {
...
color: #fff;
background-color: mediumblue;
transition-property: background-color;
}
.smooth:hover, .smooth:focus {
background-color: red;
}
Defining Duration
transition-duration
Values: Time
Identifies how much time the transition will take. It’s usually
specified in seconds (s) or milliseconds (ms).
In this example, the transition from blue to red takes .3 seconds:
.smooth {
...
color: #fff;
background-color: mediumblue;
transition-property: background-color;
transition-duration: .3s;
}
.smooth:hover, .smooth:focus {
background-color: red;
}
Timing Functions
transition-timing-function
Values: ease, linear, ease-in, ease-out, ease-in-out,
step-start, step-end, steps, cubic-bezier(#,#,#,#)
• The timing function describes the way the transition
accelerates or decelerates over time.
• It has a big impact on the feel and believability of the
animation.
• The default is ease, which starts slowly, accelerates quickly,
then slows down again at the end.
Timing Functions (cont’d)
• linear: Stays consistent from beginning to end, feels mechanical
• ease-in: Starts slowly, then speeds up
• ease-out: Starts quickly, then slows down
• ease-in-out: Similar to ease, but with less acceleration in the middle
• cubic-bezier(#,#,#,#): Defines a curve that plots acceleration
• steps(#, start or end): Divides the animation into a number of
steps. The start and end keywords indicate whether that transition
happens at the beginning or end of each step.
• step-start: Changes states in one step, at the beginning of the
duration time
• step-end: Changes states in one step, at the end of the duration time
Cubic Bezier Curves
• Acceleration can be plotted using a Bezier curve.
• Steep sections indicate quick rate of change; flat parts indicate
slow rate of change.
• The curve is defined
by the x,y coordinates
of “handles” that
control the curve.
Cubic Bezier Curves for Keywords
The curves for transition-timing-function
keyword values:
Transition Delay
transition-delay
Values: Time
Delays the start of the transition by the amount of time specified.
In this example, the transition will begin .2 seconds after the user hovers
over the element:
.smooth {
...
color: #fff;
background-color: mediumblue;
transition-property: background-color;
transition-duration: .3s;
transition-timing-function: ease-in-out;
transition-delay: 0.2s;
}
.smooth:hover, .smooth:focus {
background-color: red;
}
Shorthand transition Property
transition
Values: property duration timing-function delay
Combines all the transition properties into one declaration.
Values are separated by character spaces.
The duration time must appear before delay time.
.smooth {
...
color: #fff;
background-color: mediumblue;
transition: background-color .3s ease-in-out 0.2s;
}
Transitioning Multiple Properties
• You can set the transitions for multiple properties with one
declaration.
• Separate value sets with commas.
• This declaration smoothes out the changes in background
color, color, and letter spacing of an element:
.smooth {
…
transition: background-color 0.3s ease-out 0.2s,
color 2s ease-in,
letter-spacing 0.3s ease-out;
}
Making All Transitions Smooth
If you want the same duration, timing-function, and delay
for all your transitions, use the all keyword for
transition-property:
.smooth {
…
transition: all 0.2s ease-in-out;
}
CSS Transforms
transform
Values: rotate(), rotateX(), rotateY(), translate(),
translateX(), translateY(), scale(), scaleX(), scaleY(),
skew(), skewX(), skewY(), none
The transform property changes the shape and location of an
element when it initially renders. It is not animated but can be
with transitions.
Transforming the Angle (rotate)
Use the rotate() function as the value of transform to rotate
the element at a given angle:
img {
width: 400px;
height: 300px;
transform: rotate(-10deg);
}
Transform Origin
transform-origin
Values: Percentage, length, left, center, right, top,
bottom
The point around which an element is transformed, defined by
horizontal and vertical offsets.
Transforming Position (translate)
• Use the translate() function as the value of transform to
render an element at a new location.
• The values are an x-offset and a y-offset. When you provide
one value, it’s used for both axes.
Transforming Size (scale)
• Use the scaleX(), scaleY(), or scale function to change
the size at which an element renders.
• The value is a unitless number that specifies a size ratio.
• The scale() shorthand provides x-offset and y-offset values
(providing one value applies to both axes).
Transforming Slant (skew)
• Use the skewX(), skewY(), or skew function to change the angle
of the horizontal or vertical axes (or both).
• The value is the number of degrees the angle should be.
• The skew() shorthand provides x-offset and y-offset values
(providing one value applies it to the x-axis only).
Multiple Transforms
You can apply more than one transform type in a declaration:
img:hover, img:focus {
transform: scale(1.5) rotate(-5deg) translate(50px,30px);
}
They’re applied in the order in which they’re listed. Order matters
in the final result.
NOTE: If you apply a transform on an element in a different state (for
example, :hover), repeat all transforms applied so far to that element
or they will be overwritten.
Smoothing Out Transformations
Smooth out a transform using the transition property.
Example:
Make an element appear to rotate smoothly when the mouse
moves over it or when it’s in focus:
a:hover img.twist, a:focus img.twist {
transform: rotate(-5deg);
}
img.twist {
transition-property: transform;
transition-duration: .3s;
}
3-D Transforms
You can apply perspective to element boxes to make them
appear as though they’re in a 3-D space.
3-D Transforms (cont’d)
• Apply the perspective property to the containing element
(the lower the value, the more extreme the perspective):
ul {
...
perspective: 600;
{
• Apply one of the 3-D transform functions to each child
element:
li {
...
transform: rotateX(45deg);
{
Intro to Keyframe Animation
Keyframe animation enables you to create
transitions between a series of states
(keyframes):
1. Establish the keyframes with a
@keyframes rule:
@keyframes animation-name {
keyframe { property: value; }
/* additional keyframes */
}
2. Apply animation properties to the
element(s) that will be animated.
Intro to Keyframe Animation (cont’d)
Keyframes establish colors at each
point in the animation and give the
sequence a name (“rainbow"):
@keyframes rainbow {
0% { background-color: red; }
20% { background-color: orange; }
40% { background-color: yellow; }
60% { background-color: green; }
80% { background-color: blue; }
100% { background-color: purple;
}
}
The animation properties are applied
to the animated element (including
which keyframe sequence to use):
#magic {
…
animation-name: rainbow;
animation-duration: 5s;
animation-timing-function:
linear;
animation-iteration-count:
infinite;
animation-direction: alternate;
}

More Related Content

What's hot

Bootstrap PPT Part - 2
Bootstrap PPT Part - 2Bootstrap PPT Part - 2
Bootstrap PPT Part - 2EPAM Systems
 
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transformKenny Lee
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)GOPAL BASAK
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arraysHassan Dar
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScriptShahDhruv21
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCEAnuradha
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptFahim Abdullah
 
Dynamic CSS: Transforms, Transitions, and Animation Basics
Dynamic CSS: Transforms, Transitions, and Animation BasicsDynamic CSS: Transforms, Transitions, and Animation Basics
Dynamic CSS: Transforms, Transitions, and Animation BasicsBeth Soderberg
 
New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3Jamshid Hashimi
 

What's hot (20)

Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Bootstrap PPT Part - 2
Bootstrap PPT Part - 2Bootstrap PPT Part - 2
Bootstrap PPT Part - 2
 
Javascript
JavascriptJavascript
Javascript
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transform
 
html-css
html-csshtml-css
html-css
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Css ppt
Css pptCss ppt
Css ppt
 
Css pseudo-classes
Css pseudo-classesCss pseudo-classes
Css pseudo-classes
 
Css tables
Css tablesCss tables
Css tables
 
Javascript
JavascriptJavascript
Javascript
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
Css positioning
Css positioningCss positioning
Css positioning
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
 
Dynamic CSS: Transforms, Transitions, and Animation Basics
Dynamic CSS: Transforms, Transitions, and Animation BasicsDynamic CSS: Transforms, Transitions, and Animation Basics
Dynamic CSS: Transforms, Transitions, and Animation Basics
 
New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3
 

Similar to Chapter 18: Transitions, Transforms, and Animation

CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)창석 한
 
CSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - ImrokraftCSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - Imrokraftimrokraft
 
KEY FRAME SYSTEM-Ruby Stella mary.pptx
KEY FRAME SYSTEM-Ruby Stella mary.pptxKEY FRAME SYSTEM-Ruby Stella mary.pptx
KEY FRAME SYSTEM-Ruby Stella mary.pptxComputerScienceDepar6
 
Workshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsWorkshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsVisual Engineering
 
Les 2 motion_11
Les 2 motion_11Les 2 motion_11
Les 2 motion_11sujameryll
 
Introduction to Canvas - Toronto HTML5 User Group
Introduction to Canvas - Toronto HTML5 User GroupIntroduction to Canvas - Toronto HTML5 User Group
Introduction to Canvas - Toronto HTML5 User Groupdreambreeze
 
Introduction to Canvas - Toronto HTML5 User Group
Introduction to Canvas - Toronto HTML5 User GroupIntroduction to Canvas - Toronto HTML5 User Group
Introduction to Canvas - Toronto HTML5 User Groupbernice-chan
 
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptxHarikumar Rajasekar
 
Speed+velocity+acceleration
Speed+velocity+accelerationSpeed+velocity+acceleration
Speed+velocity+accelerationjacquibridges
 
Unit-3 overview of transformations
Unit-3 overview of transformationsUnit-3 overview of transformations
Unit-3 overview of transformationsAmol Gaikwad
 
Two dimensionaltransformations
Two dimensionaltransformationsTwo dimensionaltransformations
Two dimensionaltransformationsNareek
 
robotics presentation (2).ppt is good for the student life and easy to gain t...
robotics presentation (2).ppt is good for the student life and easy to gain t...robotics presentation (2).ppt is good for the student life and easy to gain t...
robotics presentation (2).ppt is good for the student life and easy to gain t...poojaranga2911
 

Similar to Chapter 18: Transitions, Transforms, and Animation (20)

Transition
TransitionTransition
Transition
 
Transition and tooltips.pdf
Transition and tooltips.pdfTransition and tooltips.pdf
Transition and tooltips.pdf
 
CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)
 
Animation ppt
Animation pptAnimation ppt
Animation ppt
 
Css3
Css3Css3
Css3
 
CSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - ImrokraftCSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - Imrokraft
 
KEY FRAME SYSTEM-Ruby Stella mary.pptx
KEY FRAME SYSTEM-Ruby Stella mary.pptxKEY FRAME SYSTEM-Ruby Stella mary.pptx
KEY FRAME SYSTEM-Ruby Stella mary.pptx
 
Css3animation
Css3animationCss3animation
Css3animation
 
Css3
Css3Css3
Css3
 
Workshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsWorkshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effects
 
Velocity ok
Velocity okVelocity ok
Velocity ok
 
Les 2 motion_11
Les 2 motion_11Les 2 motion_11
Les 2 motion_11
 
Introduction to Canvas - Toronto HTML5 User Group
Introduction to Canvas - Toronto HTML5 User GroupIntroduction to Canvas - Toronto HTML5 User Group
Introduction to Canvas - Toronto HTML5 User Group
 
Introduction to Canvas - Toronto HTML5 User Group
Introduction to Canvas - Toronto HTML5 User GroupIntroduction to Canvas - Toronto HTML5 User Group
Introduction to Canvas - Toronto HTML5 User Group
 
Intro to Canva
Intro to CanvaIntro to Canva
Intro to Canva
 
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
 
Speed+velocity+acceleration
Speed+velocity+accelerationSpeed+velocity+acceleration
Speed+velocity+acceleration
 
Unit-3 overview of transformations
Unit-3 overview of transformationsUnit-3 overview of transformations
Unit-3 overview of transformations
 
Two dimensionaltransformations
Two dimensionaltransformationsTwo dimensionaltransformations
Two dimensionaltransformations
 
robotics presentation (2).ppt is good for the student life and easy to gain t...
robotics presentation (2).ppt is good for the student life and easy to gain t...robotics presentation (2).ppt is good for the student life and easy to gain t...
robotics presentation (2).ppt is good for the student life and easy to gain t...
 

More from Steve Guinan

Chapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignChapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignSteve Guinan
 
Chapter 15: Floating and Positioning
Chapter 15: Floating and Positioning Chapter 15: Floating and Positioning
Chapter 15: Floating and Positioning Steve Guinan
 
Chapter 14: Box Model
Chapter 14: Box ModelChapter 14: Box Model
Chapter 14: Box ModelSteve Guinan
 
Chapter 13: Colors and Backgrounds
Chapter 13: Colors and BackgroundsChapter 13: Colors and Backgrounds
Chapter 13: Colors and BackgroundsSteve Guinan
 
Chapter 12: CSS Part 2
Chapter 12: CSS Part 2Chapter 12: CSS Part 2
Chapter 12: CSS Part 2Steve Guinan
 
Chapter 11: Intro to CSS
Chapter 11: Intro to CSSChapter 11: Intro to CSS
Chapter 11: Intro to CSSSteve Guinan
 
Chapter 23: Web Images
Chapter 23: Web ImagesChapter 23: Web Images
Chapter 23: Web ImagesSteve Guinan
 
HubSpot Student Instructions
HubSpot Student InstructionsHubSpot Student Instructions
HubSpot Student InstructionsSteve Guinan
 
Ch 5: Marking up Text
Ch 5: Marking up TextCh 5: Marking up Text
Ch 5: Marking up TextSteve Guinan
 
Ch 3: Big Concepts
Ch 3: Big ConceptsCh 3: Big Concepts
Ch 3: Big ConceptsSteve Guinan
 
Ch 2: How the Web Works
Ch 2: How the Web WorksCh 2: How the Web Works
Ch 2: How the Web WorksSteve Guinan
 
Ch 1: Getting Started
Ch 1: Getting StartedCh 1: Getting Started
Ch 1: Getting StartedSteve Guinan
 
Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7Steve Guinan
 
Intro to Web Design 6e Chapter 6
Intro to Web Design 6e Chapter 6Intro to Web Design 6e Chapter 6
Intro to Web Design 6e Chapter 6Steve Guinan
 
Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5Steve Guinan
 
Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4 Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4 Steve Guinan
 

More from Steve Guinan (20)

Chapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignChapter 17: Responsive Web Design
Chapter 17: Responsive Web Design
 
Chapter 15: Floating and Positioning
Chapter 15: Floating and Positioning Chapter 15: Floating and Positioning
Chapter 15: Floating and Positioning
 
Chapter 9: Forms
Chapter 9: FormsChapter 9: Forms
Chapter 9: Forms
 
Chapter 8: Tables
Chapter 8: TablesChapter 8: Tables
Chapter 8: Tables
 
Chapter 14: Box Model
Chapter 14: Box ModelChapter 14: Box Model
Chapter 14: Box Model
 
Chapter 13: Colors and Backgrounds
Chapter 13: Colors and BackgroundsChapter 13: Colors and Backgrounds
Chapter 13: Colors and Backgrounds
 
Chapter 12: CSS Part 2
Chapter 12: CSS Part 2Chapter 12: CSS Part 2
Chapter 12: CSS Part 2
 
Chapter 11: Intro to CSS
Chapter 11: Intro to CSSChapter 11: Intro to CSS
Chapter 11: Intro to CSS
 
Chapter 23: Web Images
Chapter 23: Web ImagesChapter 23: Web Images
Chapter 23: Web Images
 
Chapter 7: Images
Chapter 7: ImagesChapter 7: Images
Chapter 7: Images
 
HubSpot Student Instructions
HubSpot Student InstructionsHubSpot Student Instructions
HubSpot Student Instructions
 
Ch 6: Links
Ch 6: LinksCh 6: Links
Ch 6: Links
 
Ch 5: Marking up Text
Ch 5: Marking up TextCh 5: Marking up Text
Ch 5: Marking up Text
 
Ch 3: Big Concepts
Ch 3: Big ConceptsCh 3: Big Concepts
Ch 3: Big Concepts
 
Ch 2: How the Web Works
Ch 2: How the Web WorksCh 2: How the Web Works
Ch 2: How the Web Works
 
Ch 1: Getting Started
Ch 1: Getting StartedCh 1: Getting Started
Ch 1: Getting Started
 
Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7
 
Intro to Web Design 6e Chapter 6
Intro to Web Design 6e Chapter 6Intro to Web Design 6e Chapter 6
Intro to Web Design 6e Chapter 6
 
Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5
 
Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4 Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4
 

Recently uploaded

Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
Internet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxInternet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxErYashwantJagtap
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationMarko4394
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 

Recently uploaded (17)

Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Internet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxInternet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptx
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 

Chapter 18: Transitions, Transforms, and Animation

  • 2. OVERVIEW • Creating smooth transitions • Moving, rotating, and scaling elements • Combining transitions and transforms • 3-D transforms • Keyframe animation overview
  • 3. CSS Transitions • CSS transitions create a smooth change from one state to another. • They fill in the frames in between (tweening). • Example: Gradually changing a button from red to blue (through purple) when the mouse pointer hovers over it. State 1: Default State 2: When the mouse is over the element
  • 4. Transition Properties transition-property Which CSS property to change transition-duration How long the transition should take in seconds (or milliseconds) transition-timing-function The manner in which the transition accelerates transition-delay Whether there should be a pause before the transition starts and how long that pause should be (in seconds)
  • 5. Specifying the Property transition-property Values: Property-name, all, none Identifies the property that will receive a transition when it changes state. Here, we want to smooth out the change in background color when the color changes from hovering or focus: .smooth { ... color: #fff; background-color: mediumblue; transition-property: background-color; } .smooth:hover, .smooth:focus { background-color: red; }
  • 6. Defining Duration transition-duration Values: Time Identifies how much time the transition will take. It’s usually specified in seconds (s) or milliseconds (ms). In this example, the transition from blue to red takes .3 seconds: .smooth { ... color: #fff; background-color: mediumblue; transition-property: background-color; transition-duration: .3s; } .smooth:hover, .smooth:focus { background-color: red; }
  • 7. Timing Functions transition-timing-function Values: ease, linear, ease-in, ease-out, ease-in-out, step-start, step-end, steps, cubic-bezier(#,#,#,#) • The timing function describes the way the transition accelerates or decelerates over time. • It has a big impact on the feel and believability of the animation. • The default is ease, which starts slowly, accelerates quickly, then slows down again at the end.
  • 8. Timing Functions (cont’d) • linear: Stays consistent from beginning to end, feels mechanical • ease-in: Starts slowly, then speeds up • ease-out: Starts quickly, then slows down • ease-in-out: Similar to ease, but with less acceleration in the middle • cubic-bezier(#,#,#,#): Defines a curve that plots acceleration • steps(#, start or end): Divides the animation into a number of steps. The start and end keywords indicate whether that transition happens at the beginning or end of each step. • step-start: Changes states in one step, at the beginning of the duration time • step-end: Changes states in one step, at the end of the duration time
  • 9. Cubic Bezier Curves • Acceleration can be plotted using a Bezier curve. • Steep sections indicate quick rate of change; flat parts indicate slow rate of change. • The curve is defined by the x,y coordinates of “handles” that control the curve.
  • 10. Cubic Bezier Curves for Keywords The curves for transition-timing-function keyword values:
  • 11. Transition Delay transition-delay Values: Time Delays the start of the transition by the amount of time specified. In this example, the transition will begin .2 seconds after the user hovers over the element: .smooth { ... color: #fff; background-color: mediumblue; transition-property: background-color; transition-duration: .3s; transition-timing-function: ease-in-out; transition-delay: 0.2s; } .smooth:hover, .smooth:focus { background-color: red; }
  • 12. Shorthand transition Property transition Values: property duration timing-function delay Combines all the transition properties into one declaration. Values are separated by character spaces. The duration time must appear before delay time. .smooth { ... color: #fff; background-color: mediumblue; transition: background-color .3s ease-in-out 0.2s; }
  • 13. Transitioning Multiple Properties • You can set the transitions for multiple properties with one declaration. • Separate value sets with commas. • This declaration smoothes out the changes in background color, color, and letter spacing of an element: .smooth { … transition: background-color 0.3s ease-out 0.2s, color 2s ease-in, letter-spacing 0.3s ease-out; }
  • 14. Making All Transitions Smooth If you want the same duration, timing-function, and delay for all your transitions, use the all keyword for transition-property: .smooth { … transition: all 0.2s ease-in-out; }
  • 15. CSS Transforms transform Values: rotate(), rotateX(), rotateY(), translate(), translateX(), translateY(), scale(), scaleX(), scaleY(), skew(), skewX(), skewY(), none The transform property changes the shape and location of an element when it initially renders. It is not animated but can be with transitions.
  • 16. Transforming the Angle (rotate) Use the rotate() function as the value of transform to rotate the element at a given angle: img { width: 400px; height: 300px; transform: rotate(-10deg); }
  • 17. Transform Origin transform-origin Values: Percentage, length, left, center, right, top, bottom The point around which an element is transformed, defined by horizontal and vertical offsets.
  • 18. Transforming Position (translate) • Use the translate() function as the value of transform to render an element at a new location. • The values are an x-offset and a y-offset. When you provide one value, it’s used for both axes.
  • 19. Transforming Size (scale) • Use the scaleX(), scaleY(), or scale function to change the size at which an element renders. • The value is a unitless number that specifies a size ratio. • The scale() shorthand provides x-offset and y-offset values (providing one value applies to both axes).
  • 20. Transforming Slant (skew) • Use the skewX(), skewY(), or skew function to change the angle of the horizontal or vertical axes (or both). • The value is the number of degrees the angle should be. • The skew() shorthand provides x-offset and y-offset values (providing one value applies it to the x-axis only).
  • 21. Multiple Transforms You can apply more than one transform type in a declaration: img:hover, img:focus { transform: scale(1.5) rotate(-5deg) translate(50px,30px); } They’re applied in the order in which they’re listed. Order matters in the final result. NOTE: If you apply a transform on an element in a different state (for example, :hover), repeat all transforms applied so far to that element or they will be overwritten.
  • 22. Smoothing Out Transformations Smooth out a transform using the transition property. Example: Make an element appear to rotate smoothly when the mouse moves over it or when it’s in focus: a:hover img.twist, a:focus img.twist { transform: rotate(-5deg); } img.twist { transition-property: transform; transition-duration: .3s; }
  • 23. 3-D Transforms You can apply perspective to element boxes to make them appear as though they’re in a 3-D space.
  • 24. 3-D Transforms (cont’d) • Apply the perspective property to the containing element (the lower the value, the more extreme the perspective): ul { ... perspective: 600; { • Apply one of the 3-D transform functions to each child element: li { ... transform: rotateX(45deg); {
  • 25. Intro to Keyframe Animation Keyframe animation enables you to create transitions between a series of states (keyframes): 1. Establish the keyframes with a @keyframes rule: @keyframes animation-name { keyframe { property: value; } /* additional keyframes */ } 2. Apply animation properties to the element(s) that will be animated.
  • 26. Intro to Keyframe Animation (cont’d) Keyframes establish colors at each point in the animation and give the sequence a name (“rainbow"): @keyframes rainbow { 0% { background-color: red; } 20% { background-color: orange; } 40% { background-color: yellow; } 60% { background-color: green; } 80% { background-color: blue; } 100% { background-color: purple; } } The animation properties are applied to the animated element (including which keyframe sequence to use): #magic { … animation-name: rainbow; animation-duration: 5s; animation-timing-function: linear; animation-iteration-count: infinite; animation-direction: alternate; }