Home > Store

Learning CSS3 Animations and Transitions: A Hands-on Guide to Animating in CSS3 with Transforms, Transitions, Keyframes, and JavaScript

Register your product to gain access to bonus material or receive a coupon.

Learning CSS3 Animations and Transitions: A Hands-on Guide to Animating in CSS3 with Transforms, Transitions, Keyframes, and JavaScript


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2013
  • Dimensions: 7" x 9"
  • Pages: 288
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-83960-9
  • ISBN-13: 978-0-321-83960-2

For web developers building rich web and mobile applications, standards-based CSS3 offers powerful advantages over traditional Flash-based approaches - and since Apple's immensely popular iPad and iPhone don't support Flash, moving to CSS3 has become even more urgent. However, most CSS3 guides focus primarily on the basics, frustrating web developers who want to do sophisticated work. Learning CSS3 Animations and Transitions is the first book focused entirely on creating production-quality rich animations and transitions with CSS3. Leading web development trainer Alexis Goldstein covers everything web developers need to know, teaching through solid examples that help web professionals build their skills one step at a time. Readers will learn how to: * Create 2D transforms that serve as the foundation for CSS3 animations * Use transitions to make changes come alive * Master essential keyframing techniques * Combine transitions, transforms, and parallax scrolling in immersive web experiences * Transform in 3D, and animate 3D transforms * Creating increasingly complex and Flash-style animations * Build powerfully effective interactive infographics with CSS3 and HTML5 * And much more...

Sample Content

Online Sample Chapter

Working with CSS3 Animations: Tools for Browser Support

Table of Contents

Table of Contents
1. Working with CSS3 Animations     1
Intro to CSS3 Animations     1
Summary of CSS3 Animation Tools     2
  HTML5 Boilerplate     2
  Tools for Generating Vendor Prefixes     2
  -prefix-free     4
  Tools for Reviewing Browser Support     5
The Modernizr Library     5
  Leveraging the Modernizr Library     6
  CSS Fallbacks via Modernizr     7
  The Default Message for Unsupported Browsers     7
  Repeated CSS Property Definitions     11
Hardware Acceleration     11
  Viewing Hardware-Accelerated Layers in Chrome     12
  Viewing Hardware-Accelerated Layers in Safari     12
A Final Word on Working with CSS3 Animations     13
2. Building a Foundation with Transforms     15
Introducing Transforms     15
  Browser Support for transform     16
  The transform Syntax     16
Transform Functions     17
  The Effect of Transform Functions on Surrounding Elements     17
  rotate     18
  scale     22
  skew     23
t  ranslate     25
  Adding a Fallback Message for Older Browsers     26
  matrix     28
Building a Bicycle in CSS3     29
  Laying Out the Basic Skeleton     29
  Creating Bicycle Wheels with border-radius     31
  Drawing the Spokes     32
  Drawing the Frame     36
  Finishing the Bike with a Seat and Handlebars     39
  Adding a Fallback Message for Older Browsers     44
Summary     45
Challenge     46
3. Animating Elements with Transitions     47
Introduction to Transitions     47
  Browser Support for transition     47
  Creating a Simple Transition     48
  The transition Shorthand Property     49
Triggering a Transition Animation with Hover Events     49
  Transitioning Changes to the Background Color     49
  Transitioning Changes to transform Values on Hover     51
Triggering a Transition Animation with Click Events     51
  Triggering the background-color Transition in a Mobile Environment     52
  Triggering the translateX Transition in a Mobile Environment     53
Transition Properties     54
  transition-property     54
  transition-duration     55
  transition-timing-function     56
  transition-delay     56
Spinning the Bike Wheels     57
Animating the Bike to Move Across the Screen     59
  Spinning the Wheels as the Bike Moves     60
  Triggering the Animation     60
Summary     61
Challenge     61
4. Keyframe Animations     63
Introduction to Keyframe Animations     63
  Browser Support for Keyframe Animations     63
  Creating a Basic Keyframe     64
  The Components of a Keyframe     65
  Setting animation Properties     66
  Using Percentages in Keyframe Selectors     67
Controlling a Keyframe Animation with Properties     70
  animation-fill-mode     70
  animation-iteration-count     72
  animation-direction     73
  animation-delay     74
  animation-play-state     74
  The animation Shorthand Property     75
Animating a Recoiling Spring     76
  Creating the Keyframes for the Spring’s Compress and Recoil     77
  Controlling the Animation’s Playback     79
  Adding Additional Compress and Recoil Keyframes     79
Animating a Floating Balloon     81
  Applying Multiple Keyframe Animations to a Single Element     82
  Adding a Fallback Message for Older Browsers     84
Summary     86
Challenge     86
5. Creating 3D Effects with Parallax Scrolling     89
Introduction to Parallax Scrolling     89
A Three-Layer Parallax Scrolling Animation     89
  Creating the Background     90
  Animating the Midground Sprite     93
  Animating a Foreground Sprite     95
Animating Several Scenes with Parallax Scrolling     96
The Animation’s Layout and Basic Styles     97
  The Animation’s Core HTML     97
  Base Styles for the Page     98
Scene 1: Creating a Skateboarding Robot     100
  The Background for Scene 1     100
  Styling Scene 1’s Sprites     101
  Moving Scene 1’s Elements Across the Screen     102
  Triggering the Transitions via JavaScript     103
Scene 2: Moving Between Landscapes     106
  Scene 2’s HTML and CSS     107
  Scene 2’s JavaScript     107
Scene 3: Making the Robot Walk     108
  Scene 3’s HTML and CSS     108
  Scene 3’s JavaScript     110
Summary     111
Challenge     112
6. Adding Depth with 3D Transforms     113
Introduction to 3D Transforms     113
  3D Transform Properties     113
  Defining Transforms on All Three Axes     115
  Browser Support for 3D Transforms      116
Drawing a 3D Cube     116
  Creating a Containing Element for the Scene     117
  Rendering Nested Elements in 3D Space     118
  Rotating the Faces of the Cube     119
  Changing Depth with translateZ     121
  Changing the Camera Angle with perspective-origin     125
Creating a House of Cards     126
  Styling the Containing Element for the House of Cards     127
  Positioning and Styling the Cards      127
  Transforming the Cards     129
  Adjusting the Ordering of the Stacked Cards     130
  Adding a Pattern to the Card Backs     132
Summary     134
Challenge     134
7. Animating 2D and 3D Transforms     135
Basic 3D Transform Animations with Transitions     135
  Adding HTML5 Sliders to Control Rotation     136
  Rotating a 3D Object as the Slider Changes     137
  Adding Basic Styles     139
Optimizing Performance     140
  Using Transitions Instead of Keyframe Animations to Improve Performance     140
  Leveraging Hardware Acceleration with translate3d and translateZ     141
Blowing in the Wind: Animating Dandelion Seeds     141
  The Base HTML     142
  Animating the Stem Blowing in a Gust of Wind     144
  Placing and Animating the Seeds     145
  Adding More Seeds     149
  Animating Groups of Seeds     153
Summary     156
Challenge     156
8. Using Transitions and Transforms to Animate Text     157
Introduction to the Typewriter Example     157
The Animation’s Layout and Basic Styles     158
  The Animation’s Core HTML     159
  Using a Custom Font with @font-face     160
  Styling the Typewriter Roller and Paper Elements     161
Scene 1: Making the Quote Rise Up the Screen     162
  Using Keyframe Animations to Move the Quote Upward     163
  Chaining Together Multiple Keyframe Animations     164
  Using JavaScript to Trigger the Animation     165
  Revealing the Letters One at a Time with JavaScript and Keyframe Animations     165
  Determining the Post-Typing Timing     169
Scene 2: Making Text Fall     171
  Animating Falling Words     171
  Triggering Scene 2’s Animation     173
Scene 3: Scrolling Text     173
Scene 4: Growing Text     175
Scene 5: Continuing the Animation     177
  Moving the Second Part of the Quote Upward     178
  Repeating the Turn of the Roller     178
  Setting Up the Timing for the Rest of the Animation     179
Summary     180
Challenge     180
9. Building Flash-Style Animations with Keyframe Animations     181
Introduction to the Meow Street Fat Cat Animation     181
  The Animation’s Layout and Basic Styles     182
  The Basic HTML Elements for the Animation     183
  The Basic Elements and Styling for Morgan the Cat     184
  Setting Up Morgan’s Newspaper     186
  Staggering the Scenes of the Animation with JavaScript     187
Scene 1: Moving the Newspaper     188
Scene 2: Reading the Newspaper     189
  Combining Animations on Two Separate Elements     189
  The Effect of Transforms on the Stacking Context and Containing Block     190
Scene 3: Moving to and Reading Page 2     191
Scene 4: Moving the Animation Outside     193
  Zooming Out to a Larger Scene     193
  Shrinking Morgan Down as You Zoom Out     194
Scene 5: Adding Murphy, the Toughest Cat Cop on the Beat     196
  HTML and Styling for Murphy the Police Cat     196
  Using transform-origin to Align Pieces of Murphy     196
Scene 6: Knocking on Morgan’s Door     197
Scene 7: Animating a Spinning Newspaper     200
  Hiding the Previous Scenes     200
  Styling the Final Scene’s Newspaper     201
  Spinning the Newspaper and Scaling It Up     202
  Avoiding Pixelation by Scaling the Newspaper Down Initially     203
Support for Opera 12     203
  Defining Two Selectors for Each 3D Scene     203
  Applying Further Fallbacks for Opera 12     204
Summary     206
Challenge     206
10. Creating Animated Infographics     207
What Are Infographics?     207
  Image-Based Infographics     207
  CSS3-Driven Infographics     208
Visualizing Data for Mixed Drinks     209
  The Base HTML for the Infographic     210
  Creating the Base Page Styles     210
  Base HTML for the First Drink Graphic     212
  Default Drink Styles     213
  Styling the Initial Ingredient     215
  Animating the Ingredients Being Poured In     217
  Styling the Remaining Ingredient     218
  Fading in the Ingredients Labels     218
  Adding a Second Drink     219
  Adding the Remaining Drinks     222
  Citing Data Sources     222
  Supporting Older Browsers with Modernizr     223
Summary     224
Challenge     224
11. Building Interactive Infographics     225
Creating an Element to Hold the Drink Recipes     225
  Styling the Drink Recipes     226
  Hiding the Ingredients by Default     227
Unveiling the Recipe Page     228
  Sliding in the Recipe Page     228
  Making the Recipe Visible When the User Clicks a Drink     229
  Determining the Recipe for the Selected Drink     230
  Hiding an Old Recipe When a New Drink Is Clicked     232
  Adjusting the recipes Element Placement for the Second Row of Drinks     232
  Fading in the Recipe Text     233
Highlighting the Selected Ingredient     234
  Animating Changes to the Selected Ingredient     234
  Triggering the Ingredient Highlight via jQuery     235
  Ensuring Compatibility in Older Browsers     236
  Changing the Cursor     237
Summary     238
Challenge     238
Index     239


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020