Dynamic CSS: Transforms, Transitions, and Animation Basics

Beth Soderberg
Beth Soderbergdeveloper at CHIEF
DYNAMIC CSS:
TRANSFORMS, TRANSITIONS,
AND ANIMATION BASICS
WordCamp US 2015
|
|
Beth Soderberg @bethsoderberg
CHIEF @AgencyChief
"to change in form, appearance, or structure; metamorphose"
- Dictionary.com
“The CSS transform property lets you modify the coordinate space
of the CSS visual formatting model. Using it, elements can be
translated, rotated, scaled, and skewed according to the values
set.”
- Mozilla Developer Network
What is a transform?
No Transforms
transform: none;
One Transform
transform: transform-function;
Multiple Transforms
transform: transform-function transform-function transform-function;
Transforms: Syntax
Transform Functions
Rotate
Scale
Skew
Translate
... and Matrix
Rotate
Rotates an element clockwise from its current position. Counter
clockwise rotations can be achieved by using negative values.
* angles are expressed as (5deg) or (-5deg), for example.
transform: rotate(angle);
Rotate: Syntax
Examples
BOX
BOX WITH SMILEY
<div class="box"></div>
.box {
width: 3em;
height: 3em;
background: #fffc00;
}

<div class="box"><i class="fa fa-smile-o"></i></div>
.box .fa {
font-size: 2em;
line-height: 1.45em;
text-align: center;
color: #000000;
}
Rotate: Examples
ROTATE 25 DEGREES TO THE RIGHT

.box {
transform: rotate(25deg);
}
ROTATE 25 DEGREES TO THE LEFT

.box {
transform: rotate(-25deg);
}
Scale
Scales an element relative to its original size. The values specified
within scale transforms are unitless and should be thought of as a
multiplier.
X and Y axis Scale
* if only valueX is specified, valueY is assumed to be equal to valueX
transform: scale(valueX, valueY);
Just X axis Scale
transform: scaleX(valueX);
Just Y axis Scale
transform: scaleY(valueY);
Scale: Syntax
Scale: Examples
SHRINK TO HALF SIZE

.box {
transform: scale(0.5);
}
DOUBLE Y AXIS

.box {
transform: scale(1, 2);
}
Skew
Skews an element along the X and/or Y axis by an angle value.
X and Y axis Skew
* do not use
transform: skew(angleX, angleY);
Just X axis Skew
transform: skewX(angleX);
Just Y axis Skew
transform: skewY(angleY);
Skew: Syntax
Skew: Examples
SKEW LEFT

.box {
transform: skewX(25deg);
}
SKEW LEFT AND UP
 .box {
transform: skewX(25deg) skewY(25deg);
}
Translate
Moves an element vertically and/or horizontally relative to its
current position. Positive values will move the element right on the
X axis or down on the Y axis. Conversely, negative values will move
the element left on the X axis or up on the Y axis. Any regular length
value can be used (px, em, etc.).
X and Y axis translation
transform: translate(valueX, valueY);
Just X axis translation
transform: translateX(valueX);
Just Y axis translation
transform: translateY(valueY);
Translate: Syntax
Translate: Example
STARTING POINT

.box-wrap {
width: 6em;
height: 6em;
border: 5px solid #282828;
}
MOVE BOX TO BOTTOM RIGHT

.box {
transform: translate(3em, 3em);
}
Why would you use translate when you
can use more established CSS
standards for layout and formatting?
Think of translate as a more efficient way to move placement in a
transition or animation.
Transform Origin
A CSS property that defines the point from which a CSS transform
is applied to an element. By default, transform-origin is set to the
center of an element (50% 50%).
transform-origin: x-offset y-offset;
x-offset: a length or percentage from the left edge of the element's box.
y-offset: a length or percentage from the top edge of the element's box.
Accepted keywords
Transform Origin Syntax
left (0%)
center (50%)
right (100%)
top (0%)
bottom (100%)
Transform Origin: Examples

ROTATE 25 DEGREES TO THE LEFT & TRANSFORM ORIGIN AT TOP RIGHT
.box {
transform: rotate(-25deg);
transform-origin: 100% 0%;
}


ROTATE 25 DEGREES TO THE LEFT & TRANSFORM ORIGIN AT BOTTOM RIGHT
.box {
transform: rotate(-25deg);
transform-origin: right bottom;
}

Prefix Requirements
Transforms: Browser Support

9+
 

 

 

 

NOTE: 3d transforms are coming and can be used in a lot of browsers now, but they are only partially supported in IE10 and 11.
-ms-
-webkit-
"movement, passage, or change from one position, state, stage,
subject, concept, etc., to another; change"
- Dictionary.com
“The transition property is a shorthand property used to represent
up to four transition-related longhand properties [that] allow
elements to change values over a specified duration, animating the
property changes, rather than having them occur immediately.”
- CSS Tricks
What is a transition?
Transition Properties
transition-property
transition-duration
transition-timing-function
transition-delay
Shorthand
transition: property duration timing-function delay;
Longhand
transition-property: property;
transition-duration: duration;
transition-timing-function: timing-function;
transition-delay: delay;
Transitions: Syntax
Syntax
transition-property: value;
Accepted Values
Transition Property
Specifies which property or properties will be impacted by the
transition.
all (default)
none
single property name
multiple property names, separated by commas
Transitions: Example Stage 1
Transition Property Only
STARTING STATE

.box {
transition-property: color, background-color, width;
color: #000000;
background-color: #fffc00;
width: 3em;
}
ACTIVE STATE

.box:hover {
color: #FFFFFF;
background-color: #CA0164;
width: 3.6em;
}
Syntax
transition-duration: value;
Accepted Values
Transition Duration Property
Specifies the amount of time the transition will take.
time in seconds (s) or milliseconds (ms)
multiple time values, separated by commas
initial
inherit
Transitions: Example Stage 2
Transition Property + Duration
STARTING STATE

.box {
transition-property: color, background-color, width;
transition-duration: 2s;
color: #000000;
background-color: #fffc00;
width: 3em;
}
ACTIVE STATE

.box:hover {
color: #FFFFFF;
background-color: #CA0164;
width: 3.6em;
}
Syntax
transition-timing-function: value;
Accepted Values
ease
linear
ease-in
ease-out
ease-in-out
step-start
step-end
custom cubic Bézier curve value
custom stepping function value
Transition Timing Property
Specifies the pace at which the transition will run.
For an in-depth explanation of the transition timing property, check out this article: http://www.the-art-of-web.com/css/timing-
function/
Transitions: Example Stage 3
Transition Property + Duration + Timing
STARTING STATE

.box {
transition-property: color, background-color, width;
transition-duration: 2s;
transition-timing-function: ease-in;
color: #000000;
background-color: #fffc00;
width: 3em;
}
ACTIVE STATE

.box:hover {
color: #ffffff;
background-color: #ca0164;
width: 3.6em;
}
Syntax
transition-delay: value;
Accepted Values
Transition Delay Property
Specifies when the transition will start relative to the instant the
property value changes.
time in seconds (s) or milliseconds (ms)
multiple time values, separated by commas
initial
inherit
Transitions: Example Stage 4
Transition Property + Duration + Timing + Delay
STARTING STATE

.box {
transition-property: color, background-color, width;
transition-duration: 2s;
transition-timing-function: ease-in;
transition-delay: 3s;
color: #000000;
background-color: #fffc00;
width: 3em;
}
ACTIVE STATE

.box:hover {
color: #FFFFFF;
background-color: #CA0164;
width: 3.6em;
}
Prefix Requirements
Transitions: Browser Support

10+
 

 

 

 

-webkit-
"the state or condition of being animated"
"containing representations of animals or mechanical objects that
appear to move as real ones do"
- Dictionary.com
“A way for authors to animate the values of CSS properties over
time, using keyframes. The behavior of these keyframe animations
can be controlled by specifying their duration, number of repeats,
and repeating behavior.”
- W3C Draft Specification
What is an animation?
Required Properties
Optional Properties
Animation: Keyframes
Keyframes establish the behavior of an animation over time.
animation-duration
animation-name
animation-timing-function
animation-delay
animation-iteration-count
animation-direction
animation-fill-mode
animation-play-state
Syntax
animation-duration: value;
Accepted Values
Animation: Animation Duration
Property
Specifies the length of time one cycle of the animation will take.
Time in seconds (s) or milliseconds (ms)
Syntax
animation-name: [custom-value];
Accepted values
Animations: Animation Name Property
Specifies the animation/s that should be applied to the CSS
element.
Custom string with no spaces
Syntax
animation-iteration-count: value;
Accepted values
Animations: Animation Interation
Count Property
Specifies the number of times the animation cycle should run.
a number
infinite
initial
inherit
.element {
animation-duration: value;
animation-name: custom-value;
}
Animation: Syntax to Call Animation
*Optional animation properties would be included in the same code block as animation-duration and animation-name.
@keyframes animation-name {
keyframe-location {
css-properties;
}
keyframe-location {
css-properties;
}
}
Animation: Keyframes Syntax
animation name: the animation-name string from your CSS
keyframe location: waypoint of the animation
Can either be percentages between 0-100% or in the case of animations with only two waypoints, the keywords “from” and “to.”
CSS properties: the CSS properties that change throughout the
animation. Not all CSS properties are “animatable.”
A detailed list of which properties are and are not able to be animated is located here: https://developer.mozilla.org/en-
US/docs/Web/CSS/CSS_animated_properties
Animations: Example

.box {
animation-duration: 1s;
animation-name: zoom-pulse;
animation-iteration-count: infinite;
}
@keyframes zoom-pulse {
0% { transform: rotate(-9deg) scale(0.8); }
17% { transform: rotate(-3deg) scale(1); }
34% { transform: rotate(3deg) scale(1.2); }
51% { transform: rotate(9deg) scale(1.4); }
68% { transform: rotate(3deg) scale(1.2); }
85% { transform: rotate(-3deg) scale(1); }
100% { transform: rotate(-9deg) scale(0.8); }
}
animation-name: none;
animation-duration: 0s;
animation-timing-function: ease;
animation-delay: 0s;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: none;
animation-play-state: running;
Animations: Default Animation
Property Values
Prefix Requirements
Keyframe Animations:
Browser Support

10+
 

 

 

 

-webkit-
W3C Working Drafts
Books
Blog Posts
Where to Learn More
Transforms:
Transitions:
Animations:
http://www.w3.org/TR/css3-2d-transforms/
http://www.w3.org/TR/css3-transitions/
http://www.w3.org/TR/css3-animations/
, Kirupa Chinnathambi
, Alexis Goldstein
Animation in HTML, CSS, and JavaScript
Learning CSS3 Animations and Transitions
http://www.responsivegeometry.com/code/dynamic-css
THANK YOU!
Beth
twitter.com/bethsoderberg
slideshare.net/bethsoderberg
bethsoderberg.com
responsivegeometry.com
CHIEF
twitter.com/agencychief
agencychief.com
This Presentation
Slides: slideshare.net/bethsoderberg/dynamic-css
1 of 46

Recommended

Css animation by
Css animationCss animation
Css animationAaron King
4.8K views23 slides
CSS Grid by
CSS GridCSS Grid
CSS GridDigital Surgeons
2.7K views33 slides
Flexbox and Grid Layout by
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid LayoutRachel Andrew
7K views98 slides
Flexbox by
FlexboxFlexbox
FlexboxNetcetera
5.7K views64 slides
CSS Animations & Transitions by
CSS Animations & TransitionsCSS Animations & Transitions
CSS Animations & TransitionsEdward Meehan
2.3K views16 slides
CSS Basics by
CSS BasicsCSS Basics
CSS BasicsSanjeev Kumar
1.5K views23 slides

More Related Content

What's hot

CSS Transitions, Transforms, Animations by
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations Rob LaPlaca
6.9K views34 slides
Css by
CssCss
CssHemant Saini
2K views15 slides
Javascript essentials by
Javascript essentialsJavascript essentials
Javascript essentialsBedis ElAchèche
1.5K views54 slides
Understanding flex box CSS Day 2016 by
Understanding flex box CSS Day 2016Understanding flex box CSS Day 2016
Understanding flex box CSS Day 2016Davide Di Pumpo
2K views72 slides
CSS3, Media Queries, and Responsive Design by
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignZoe Gillenwater
6.5K views63 slides
CSS Flexbox (flexible box layout) by
CSS Flexbox (flexible box layout)CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)Woodridge Software
1.4K views17 slides

What's hot(20)

CSS Transitions, Transforms, Animations by Rob LaPlaca
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
Rob LaPlaca6.9K views
Understanding flex box CSS Day 2016 by Davide Di Pumpo
Understanding flex box CSS Day 2016Understanding flex box CSS Day 2016
Understanding flex box CSS Day 2016
Davide Di Pumpo2K views
CSS3, Media Queries, and Responsive Design by Zoe Gillenwater
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive Design
Zoe Gillenwater6.5K views
HTML CSS Basics by Mai Moustafa
HTML CSS BasicsHTML CSS Basics
HTML CSS Basics
Mai Moustafa47.5K views
Introduction to flexbox by Jyoti Gautam
Introduction  to  flexboxIntroduction  to  flexbox
Introduction to flexbox
Jyoti Gautam135 views
Html / CSS Presentation by Shawn Calvert
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert78.8K views
CSS Flexbox and Grid: The future of website layouts - DN Scrum Breakfast - Au... by Scrum Breakfast Vietnam
CSS Flexbox and Grid: The future of website layouts - DN Scrum Breakfast - Au...CSS Flexbox and Grid: The future of website layouts - DN Scrum Breakfast - Au...
CSS Flexbox and Grid: The future of website layouts - DN Scrum Breakfast - Au...
JavaScript Programming by Sehwan Noh
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh14.9K views
Introduction to HTML5 by Gil Fink
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
Gil Fink13.7K views
HTML5 - Forms by tina1357
HTML5 - FormsHTML5 - Forms
HTML5 - Forms
tina13571.5K views

Viewers also liked

CSS3 filterとtransformをtransition, animationでアニメーション by
CSS3 filterとtransformをtransition, animationでアニメーションCSS3 filterとtransformをtransition, animationでアニメーション
CSS3 filterとtransformをtransition, animationでアニメーションHiroaki Okubo
4.8K views15 slides
Media Query by
Media QueryMedia Query
Media Queryipower softwares
480 views6 slides
JS.Chi CSS Animations by
JS.Chi CSS AnimationsJS.Chi CSS Animations
JS.Chi CSS AnimationsJustin Meyer
1.1K views15 slides
Css3animation by
Css3animationCss3animation
Css3animationVadim Spiridenko
1.3K views10 slides
Honey con 2014 by
Honey con 2014Honey con 2014
Honey con 2014Ted Hsu
639 views17 slides
Ad 8 by
Ad 8Ad 8
Ad 8juanan10
442 views3 slides

Viewers also liked(20)

CSS3 filterとtransformをtransition, animationでアニメーション by Hiroaki Okubo
CSS3 filterとtransformをtransition, animationでアニメーションCSS3 filterとtransformをtransition, animationでアニメーション
CSS3 filterとtransformをtransition, animationでアニメーション
Hiroaki Okubo4.8K views
JS.Chi CSS Animations by Justin Meyer
JS.Chi CSS AnimationsJS.Chi CSS Animations
JS.Chi CSS Animations
Justin Meyer1.1K views
Honey con 2014 by Ted Hsu
Honey con 2014Honey con 2014
Honey con 2014
Ted Hsu639 views
Ad 8 by juanan10
Ad 8Ad 8
Ad 8
juanan10442 views
The Future is now! Flexbox und fancy Stuff im Responsive Webdesign by Peter Rozek
The Future is now! Flexbox und fancy Stuff im Responsive WebdesignThe Future is now! Flexbox und fancy Stuff im Responsive Webdesign
The Future is now! Flexbox und fancy Stuff im Responsive Webdesign
Peter Rozek1.4K views
Workshop 18: CSS Animations & cool effects by Visual Engineering
Workshop 18: CSS Animations & cool effectsWorkshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effects
Visual Engineering1.2K views
The Box Model by sdireland
The Box ModelThe Box Model
The Box Model
sdireland1.6K views
Intro to OOCSS Workshop by Julie Cameron
Intro to OOCSS WorkshopIntro to OOCSS Workshop
Intro to OOCSS Workshop
Julie Cameron1.6K views
Cascading Style Sheets - Part 02 by Hatem Mahmoud
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
Hatem Mahmoud4.5K views
CSS Layouting #4 : Float by Sandhika Galih
CSS Layouting #4 : FloatCSS Layouting #4 : Float
CSS Layouting #4 : Float
Sandhika Galih11.7K views
Efficient, maintainable CSS by Russ Weakley
Efficient, maintainable CSSEfficient, maintainable CSS
Efficient, maintainable CSS
Russ Weakley41.3K views

Similar to Dynamic CSS: Transforms, Transitions, and Animation Basics

Chapter 18: Transitions, Transforms, and Animation by
Chapter 18: Transitions, Transforms, and AnimationChapter 18: Transitions, Transforms, and Animation
Chapter 18: Transitions, Transforms, and AnimationSteve Guinan
269 views26 slides
CSS3 TTA (Transform Transition Animation) by
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)창석 한
1.2K views48 slides
Css3 by
Css3Css3
Css3Knoldus Inc.
2K views36 slides
Css3 by
Css3Css3
Css3Rahma Boufalgha
636 views54 slides
CSS3 Animation for beginners - Imrokraft by
CSS3 Animation for beginners - ImrokraftCSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - Imrokraftimrokraft
730 views18 slides
MTA managing the graphical interface by using css by
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using cssDhairya Joshi
390 views49 slides

Similar to Dynamic CSS: Transforms, Transitions, and Animation Basics(20)

Chapter 18: Transitions, Transforms, and Animation by Steve Guinan
Chapter 18: Transitions, Transforms, and AnimationChapter 18: Transitions, Transforms, and Animation
Chapter 18: Transitions, Transforms, and Animation
Steve Guinan269 views
CSS3 TTA (Transform Transition Animation) by 창석 한
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)
창석 한1.2K views
CSS3 Animation for beginners - Imrokraft by imrokraft
CSS3 Animation for beginners - ImrokraftCSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - Imrokraft
imrokraft730 views
MTA managing the graphical interface by using css by Dhairya Joshi
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using css
Dhairya Joshi390 views
CSS3 Transforms Transitions and Animations by Inayaili León
CSS3 Transforms Transitions and AnimationsCSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and Animations
Inayaili León2.3K views
CSS3 Transitions by hstryk
CSS3 TransitionsCSS3 Transitions
CSS3 Transitions
hstryk1.1K views
Css3 transitions and animations + graceful degradation with jQuery by Andrea Verlicchi
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQuery
Andrea Verlicchi7.1K views
Designing Your Next Generation Web Pages with CSS3 by Gil Fink
Designing Your Next Generation Web Pages with CSS3Designing Your Next Generation Web Pages with CSS3
Designing Your Next Generation Web Pages with CSS3
Gil Fink695 views
Solving CSS Problems With eCSStender - An Event Apart - Chicago 2009 by Aaron Gustafson
Solving CSS Problems With eCSStender - An Event Apart - Chicago 2009Solving CSS Problems With eCSStender - An Event Apart - Chicago 2009
Solving CSS Problems With eCSStender - An Event Apart - Chicago 2009
Aaron Gustafson1.6K views
Choosing your animation adventure - Ffronteers Conf 2017 by Val Head
Choosing your animation adventure - Ffronteers Conf 2017Choosing your animation adventure - Ffronteers Conf 2017
Choosing your animation adventure - Ffronteers Conf 2017
Val Head1.3K views
HTML5 and CSS3 Shizzle by Chris Mills
HTML5 and CSS3 ShizzleHTML5 and CSS3 Shizzle
HTML5 and CSS3 Shizzle
Chris Mills1.1K views

Recently uploaded

.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV by
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTVSplunk
86 views20 slides
Uni Systems for Power Platform.pptx by
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptxUni Systems S.M.S.A.
38 views21 slides
PharoJS - Zürich Smalltalk Group Meetup November 2023 by
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023Noury Bouraqadi
113 views17 slides
Special_edition_innovator_2023.pdf by
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdfWillDavies22
14 views6 slides
Melek BEN MAHMOUD.pdf by
Melek BEN MAHMOUD.pdfMelek BEN MAHMOUD.pdf
Melek BEN MAHMOUD.pdfMelekBenMahmoud
14 views1 slide
Java Platform Approach 1.0 - Picnic Meetup by
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
25 views39 slides

Recently uploaded(20)

.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV by Splunk
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk86 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi113 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2214 views
Future of Learning - Yap Aye Wee.pdf by NUS-ISS
Future of Learning - Yap Aye Wee.pdfFuture of Learning - Yap Aye Wee.pdf
Future of Learning - Yap Aye Wee.pdf
NUS-ISS38 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software91 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada119 views
handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex19 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab11 views
[2023] Putting the R! in R&D.pdf by Eleanor McHugh
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh38 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb12 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
Data-centric AI and the convergence of data and model engineering: opportunit... by Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier29 views

Dynamic CSS: Transforms, Transitions, and Animation Basics

  • 1. DYNAMIC CSS: TRANSFORMS, TRANSITIONS, AND ANIMATION BASICS WordCamp US 2015 | | Beth Soderberg @bethsoderberg CHIEF @AgencyChief
  • 2. "to change in form, appearance, or structure; metamorphose" - Dictionary.com “The CSS transform property lets you modify the coordinate space of the CSS visual formatting model. Using it, elements can be translated, rotated, scaled, and skewed according to the values set.” - Mozilla Developer Network What is a transform?
  • 3. No Transforms transform: none; One Transform transform: transform-function; Multiple Transforms transform: transform-function transform-function transform-function; Transforms: Syntax
  • 5. Rotate Rotates an element clockwise from its current position. Counter clockwise rotations can be achieved by using negative values.
  • 6. * angles are expressed as (5deg) or (-5deg), for example. transform: rotate(angle); Rotate: Syntax
  • 7. Examples BOX BOX WITH SMILEY <div class="box"></div> .box { width: 3em; height: 3em; background: #fffc00; }  <div class="box"><i class="fa fa-smile-o"></i></div> .box .fa { font-size: 2em; line-height: 1.45em; text-align: center; color: #000000; }
  • 8. Rotate: Examples ROTATE 25 DEGREES TO THE RIGHT  .box { transform: rotate(25deg); } ROTATE 25 DEGREES TO THE LEFT  .box { transform: rotate(-25deg); }
  • 9. Scale Scales an element relative to its original size. The values specified within scale transforms are unitless and should be thought of as a multiplier.
  • 10. X and Y axis Scale * if only valueX is specified, valueY is assumed to be equal to valueX transform: scale(valueX, valueY); Just X axis Scale transform: scaleX(valueX); Just Y axis Scale transform: scaleY(valueY); Scale: Syntax
  • 11. Scale: Examples SHRINK TO HALF SIZE  .box { transform: scale(0.5); } DOUBLE Y AXIS  .box { transform: scale(1, 2); }
  • 12. Skew Skews an element along the X and/or Y axis by an angle value.
  • 13. X and Y axis Skew * do not use transform: skew(angleX, angleY); Just X axis Skew transform: skewX(angleX); Just Y axis Skew transform: skewY(angleY); Skew: Syntax
  • 14. Skew: Examples SKEW LEFT  .box { transform: skewX(25deg); } SKEW LEFT AND UP  .box { transform: skewX(25deg) skewY(25deg); }
  • 15. Translate Moves an element vertically and/or horizontally relative to its current position. Positive values will move the element right on the X axis or down on the Y axis. Conversely, negative values will move the element left on the X axis or up on the Y axis. Any regular length value can be used (px, em, etc.).
  • 16. X and Y axis translation transform: translate(valueX, valueY); Just X axis translation transform: translateX(valueX); Just Y axis translation transform: translateY(valueY); Translate: Syntax
  • 17. Translate: Example STARTING POINT  .box-wrap { width: 6em; height: 6em; border: 5px solid #282828; } MOVE BOX TO BOTTOM RIGHT  .box { transform: translate(3em, 3em); }
  • 18. Why would you use translate when you can use more established CSS standards for layout and formatting? Think of translate as a more efficient way to move placement in a transition or animation.
  • 19. Transform Origin A CSS property that defines the point from which a CSS transform is applied to an element. By default, transform-origin is set to the center of an element (50% 50%).
  • 20. transform-origin: x-offset y-offset; x-offset: a length or percentage from the left edge of the element's box. y-offset: a length or percentage from the top edge of the element's box. Accepted keywords Transform Origin Syntax left (0%) center (50%) right (100%) top (0%) bottom (100%)
  • 21. Transform Origin: Examples  ROTATE 25 DEGREES TO THE LEFT & TRANSFORM ORIGIN AT TOP RIGHT .box { transform: rotate(-25deg); transform-origin: 100% 0%; }   ROTATE 25 DEGREES TO THE LEFT & TRANSFORM ORIGIN AT BOTTOM RIGHT .box { transform: rotate(-25deg); transform-origin: right bottom; } 
  • 22. Prefix Requirements Transforms: Browser Support  9+             NOTE: 3d transforms are coming and can be used in a lot of browsers now, but they are only partially supported in IE10 and 11. -ms- -webkit-
  • 23. "movement, passage, or change from one position, state, stage, subject, concept, etc., to another; change" - Dictionary.com “The transition property is a shorthand property used to represent up to four transition-related longhand properties [that] allow elements to change values over a specified duration, animating the property changes, rather than having them occur immediately.” - CSS Tricks What is a transition?
  • 25. Shorthand transition: property duration timing-function delay; Longhand transition-property: property; transition-duration: duration; transition-timing-function: timing-function; transition-delay: delay; Transitions: Syntax
  • 26. Syntax transition-property: value; Accepted Values Transition Property Specifies which property or properties will be impacted by the transition. all (default) none single property name multiple property names, separated by commas
  • 27. Transitions: Example Stage 1 Transition Property Only STARTING STATE  .box { transition-property: color, background-color, width; color: #000000; background-color: #fffc00; width: 3em; } ACTIVE STATE  .box:hover { color: #FFFFFF; background-color: #CA0164; width: 3.6em; }
  • 28. Syntax transition-duration: value; Accepted Values Transition Duration Property Specifies the amount of time the transition will take. time in seconds (s) or milliseconds (ms) multiple time values, separated by commas initial inherit
  • 29. Transitions: Example Stage 2 Transition Property + Duration STARTING STATE  .box { transition-property: color, background-color, width; transition-duration: 2s; color: #000000; background-color: #fffc00; width: 3em; } ACTIVE STATE  .box:hover { color: #FFFFFF; background-color: #CA0164; width: 3.6em; }
  • 30. Syntax transition-timing-function: value; Accepted Values ease linear ease-in ease-out ease-in-out step-start step-end custom cubic Bézier curve value custom stepping function value Transition Timing Property Specifies the pace at which the transition will run. For an in-depth explanation of the transition timing property, check out this article: http://www.the-art-of-web.com/css/timing- function/
  • 31. Transitions: Example Stage 3 Transition Property + Duration + Timing STARTING STATE  .box { transition-property: color, background-color, width; transition-duration: 2s; transition-timing-function: ease-in; color: #000000; background-color: #fffc00; width: 3em; } ACTIVE STATE  .box:hover { color: #ffffff; background-color: #ca0164; width: 3.6em; }
  • 32. Syntax transition-delay: value; Accepted Values Transition Delay Property Specifies when the transition will start relative to the instant the property value changes. time in seconds (s) or milliseconds (ms) multiple time values, separated by commas initial inherit
  • 33. Transitions: Example Stage 4 Transition Property + Duration + Timing + Delay STARTING STATE  .box { transition-property: color, background-color, width; transition-duration: 2s; transition-timing-function: ease-in; transition-delay: 3s; color: #000000; background-color: #fffc00; width: 3em; } ACTIVE STATE  .box:hover { color: #FFFFFF; background-color: #CA0164; width: 3.6em; }
  • 34. Prefix Requirements Transitions: Browser Support  10+             -webkit-
  • 35. "the state or condition of being animated" "containing representations of animals or mechanical objects that appear to move as real ones do" - Dictionary.com “A way for authors to animate the values of CSS properties over time, using keyframes. The behavior of these keyframe animations can be controlled by specifying their duration, number of repeats, and repeating behavior.” - W3C Draft Specification What is an animation?
  • 36. Required Properties Optional Properties Animation: Keyframes Keyframes establish the behavior of an animation over time. animation-duration animation-name animation-timing-function animation-delay animation-iteration-count animation-direction animation-fill-mode animation-play-state
  • 37. Syntax animation-duration: value; Accepted Values Animation: Animation Duration Property Specifies the length of time one cycle of the animation will take. Time in seconds (s) or milliseconds (ms)
  • 38. Syntax animation-name: [custom-value]; Accepted values Animations: Animation Name Property Specifies the animation/s that should be applied to the CSS element. Custom string with no spaces
  • 39. Syntax animation-iteration-count: value; Accepted values Animations: Animation Interation Count Property Specifies the number of times the animation cycle should run. a number infinite initial inherit
  • 40. .element { animation-duration: value; animation-name: custom-value; } Animation: Syntax to Call Animation *Optional animation properties would be included in the same code block as animation-duration and animation-name.
  • 41. @keyframes animation-name { keyframe-location { css-properties; } keyframe-location { css-properties; } } Animation: Keyframes Syntax animation name: the animation-name string from your CSS keyframe location: waypoint of the animation Can either be percentages between 0-100% or in the case of animations with only two waypoints, the keywords “from” and “to.” CSS properties: the CSS properties that change throughout the animation. Not all CSS properties are “animatable.” A detailed list of which properties are and are not able to be animated is located here: https://developer.mozilla.org/en- US/docs/Web/CSS/CSS_animated_properties
  • 42. Animations: Example  .box { animation-duration: 1s; animation-name: zoom-pulse; animation-iteration-count: infinite; } @keyframes zoom-pulse { 0% { transform: rotate(-9deg) scale(0.8); } 17% { transform: rotate(-3deg) scale(1); } 34% { transform: rotate(3deg) scale(1.2); } 51% { transform: rotate(9deg) scale(1.4); } 68% { transform: rotate(3deg) scale(1.2); } 85% { transform: rotate(-3deg) scale(1); } 100% { transform: rotate(-9deg) scale(0.8); } }
  • 43. animation-name: none; animation-duration: 0s; animation-timing-function: ease; animation-delay: 0s; animation-iteration-count: 1; animation-direction: normal; animation-fill-mode: none; animation-play-state: running; Animations: Default Animation Property Values
  • 44. Prefix Requirements Keyframe Animations: Browser Support  10+             -webkit-
  • 45. W3C Working Drafts Books Blog Posts Where to Learn More Transforms: Transitions: Animations: http://www.w3.org/TR/css3-2d-transforms/ http://www.w3.org/TR/css3-transitions/ http://www.w3.org/TR/css3-animations/ , Kirupa Chinnathambi , Alexis Goldstein Animation in HTML, CSS, and JavaScript Learning CSS3 Animations and Transitions http://www.responsivegeometry.com/code/dynamic-css