banner



How To Make A Css Animation Repeat

Animations can exist powerful tools for engaging and delighting visitors on your site. They can make the loading experience more entertaining, directly the visitor's middle to an important element on the folio, and improve usability.

While rendering animations on the web isn't new, the process is. Blitheness used to require JavaScript, which is considered 1 of the most hard coding languages to learn, or Flash, an Adobe product that you accept to pay a monthly fee to use. In the past decade, many developers accept shifted away from JavaScript and Flash to using CSS for animations. Almost already know CSS — plus information technology's free!

Download Now: Free Intro Guide to Java & JavaScript

To help you lot understand this web design trend, nosotros'll walk through what CSS blitheness is, different types of CSS animation, and examples of animations being used on live sites.

  1. What is CSS blitheness?

  2. Types of CSS Animation

  3. CSS Animation Tutorial

  4. CSS Animation Examples

  5. CSS Transition vs. Animation

  6. CSS 3D Animation

What is CSS animation?

Allow'south say you want to use multiple CSS style configurations — similar unlike colors, levels of opacity, edge radiuses, and and so on— on a single folio element. To have elements gradually change from ane style to another, you tin can create a CSS animation.

There are dozens of animatable CSS propertiesyou can cull from. Yous can take a progress bar show how quickly your site is loading, a button modify colors when a visitor hovers over it, and your logo bounce in from the left side of the screen. You can fifty-fifty animate an element's padding area to transition between colors. Animations similar these tin help make your spider web design more than cohesive and more memorable.

Let's take a expect at some specific types of animation below.

Types of CSS Animation

With CSS animation, elements can exist shifted, rotated, slanted, squashed, spun, and stretched on the page. They tin be bounced beyond the folio and interact with each other in all sorts of interesting means.

Since in that location are thousands of types of CSS animation, we'll limit our focus to some of the most common — and coolest! — types you'll see on the web.

CSS Text Animation

Blithe typography can immediately capture the attention of your visitors. Of the many ways you can animate text on your site with CSS, adding a rainbow effect, shadow, glitch result, and gooey effect are among the near mutual.

Below is an example of a handwriting blitheness in which the visitor watches the text being written on the page.

logo looks like it's being written on page using css text animation

Source

CSS Color Animation

You'll often see the background of a web page blithe to alternating betwixt colors, as in the case below.

square alternating background colors using css color animation

Source

CSS colour animations can likewise be applied to text, buttons, borders, and other elements on the page, making them ideal for drawing the visitor's heart to a specific point on the page.

Slide-in Animation

Using this CSS animation, y'all tin take an chemical element slide in from the meridian, bottom, left, or correct of the screen to grab the visitor'south heart. You can likewise combine the slide-in animation with other effects to farther customize your design. In the example below, the slide-in animation is combined with a blurred text consequence so that the company proper noun slowly comes into focus.

animista logo sliding from bottom of page using CSS slide-in animation

Source

CSS Rotate Animation

You tin can use CSS to rotate an chemical element in 2D or 3D space. This blitheness is ofttimes combined with other animations to bear witness elements in movement. Take the example of the rocket below. It'southward not only translated from the bottom left of the screen to the acme right over a catamenia of three seconds, just likewise rotated 70 degrees in a clockwise management over the kickoff two seconds.

plane icon starting vertical then flying horizontally  using css rotate animation

Source

CSS Wave Blitheness

The CSS Moving ridge animation is a unique utilize case of the rotate animation. To create a CSS moving ridge animation, you demand to create multiple HTML objects to stand for your waves. Then you lot'll apply the rotate animation to each wave with different groundwork colors and values for the animation-timing property. Y'all can also experiment with opacity.

The consequence will look something like the demo below.

Background moving like waves using CSS wave animation

Source

CSS Glow Animation

CSS glow animations can contribute to the ambiance of your site. For example, to promote an event on your site, you lot might add neon glow text against a dark background to set a party mood. You can also utilise the glow effect on buttons, borders, loading animations, hover animations, and more than.

In the example below, the slope push button glows when the user hovers over it and then that clicking it seems more appealing.

button lights up when mouse hovers using css glow animation

Source

CSS Bounce Animation

Let's say yous don't want an element to slide in. You lot want it to bounce in for a grander entrance. In that case, you can apply the CSS bounciness animation. Coding this animation requires a few animation subproperties, including the timing and delay part, to be configured to brand the element's bounciness feel more natural.

This animation is particularly common on loading pages, as shown in the example below.

three dot loading animation using CSS bounce animation

Source

CSS Fade-in Blitheness

Using CSS, y'all can add the fade-in animation to images and text on your site. Beneath you'll meet an image gradually appear from the top of the screen. This blitheness is specially constructive with this image because it mimics the movement of a boat lazily globe-trotting downward a river.

image becomes more opaque as it moves toward bottom of page using CSS fade-in animation

Source

For more interactivity, you tin pattern the paradigm or text to fade-in when a mouse hovers over the element or every bit a visitor scrolls. Please annotation that the latter will require both CSS and Javascript because it'south more complicated.

CSS Hover Blitheness

To enhance your site's interactivity, you can create a CSS hover animation. This type of animation occurs when a site visitor hovers over an chemical element on the page. You lot tin can have elements zoom, flip, rotate, or fifty-fifty stop playing on hover. In the instance below, the CTA button changes in size and lets off some sparks when the visitor hovers.

button becomes smaller and releases dots when mouse hoveringusing CSS hover animation

Source

Infinite Loading Animation

When visiting some sites, you lot'll watch them slowly load: ordinarily the championship comes start, so the plain body text comes, and so the images, and so on. On other sites, that procedure will exist subconscious and instead, you'll see an blitheness.

The space loading animation is but i of the five website loading animations you lot can make in CSS to help reduce the user's perception of waiting. Since this blazon of animation lets visitors know the site is loading without specifying how long they'll accept to wait, this is perfect when load fourth dimension is unknown.

Here's a creative one past designer Hoang Nguyen.

Infinite loading CSS animation typeParallax Scrolling

Parallax scrolling is a visual technique in which elements in the background move at a different speed than the foreground as you scroll. This creates an illusion of depth or a "faux-3D effect" that's intended to make your visitor's browsing experience more interesting.

Demo site with specific type of CSS animation type called parallax scrolling

Source

Now that we're familiar with different types of CSS animations, allow'due south walk through the process of creating one. Before we dive into the tutorial, let'due south take a closer look at the fundamental chemical element of a CSS blitheness: the @keyframes at-rule.

Keyframe CSS

In CSS, keyframes are used to specify how an animated element should appear throughout the animation cycle.

At to the lowest degree ane keyframe must be defined in a CSS animation, but information technology's most common to meet at least two. Typically, they draw the start and finish of the blitheness. Additional keyframes can be defined to depict any intermediate steps between the showtime and end of the animation wheel.

Keyframes are specified using the @keyframes at-rule. Let's take a look at the syntax of this at-rule.

@keyframes at-rule

The @keyframes at-rule is written equally follows:

                              
@keyframes animation-name {

<percentage> {
property: value
}

<pct> {
property: value
}

}

Note that the @keyframes rule must have the same value every bit the animation-proper noun property. This allows the browser to lucifer an animation to its keyframes declaration.

The rule must contain at least one keyframe to describe how the animated element should render at a given time during the blitheness sequence. Keyframe selectors can use percentages to specify when they have identify along the animation cycle. If they are specifying 0% (the starting time of the animation cycle) or 100% (the stop of the animation cycle), and then they can use the keywords from or to instead.

Allow's look at an example. Say the animated element is a div, its animation proper noun is "slide-right," and its animation wheel is four seconds.

Hither's the CSS for the blithe div:

                              
div {
animation-name: slide-right;
animation-duration: 4s;
}

To control how the div renders at a given time during the animation sequence, yous tin add a @keyframes at-rule with two or more keyframe selectors.

Let's say you desire to add three keyframe selectors. The outset selector defines that at the start of the blitheness, the left margin of the div is 0px. The second selector defines that at the midway point of the animation cycle (or at two seconds), the left margin is 100px. The third selector defines that at the end of the animation (or at four seconds, the margin is 200px. Here's how that rule is written:

                              
@keyframes slide-right {

from {
margin-left: 0px;
}

l% {
margin-left: 100px;
}

to {
margin-left: 200px;
}

}

Here'due south the result:

Encounter the Pen by HubSpot (@hubspot) on CodePen.

CSS Blitheness Tutorial

Yous tin create CSS animations from scratch with only a flake of code.

CSS animations are made upward of two parts: keyframes and animation properties. So to create a CSS animation, you accept to define its keyframes and animation properties. Let's wait at how beneath.

Step i: Ascertain your blitheness'due south keyframes.

The beginning part of a CSS blitheness is a ready of keyframes. Since keyframes indicate the beginning and end of the animation, every bit well as any intermediate steps, they use percentages. These percentages indicate at which bespeak in the animation sequence they take place.

Say y'all want to style an element and so information technology slides in from the right side of the browser window, similar so.

CSS animation tutorialBut let'south say you want the blithe element to be a paragraph (the <p> chemical element) instead, like in the case by Mozilla. For this slide-in animation, there are simply ii keyframes.

The get-go occurs at 0% or the first moment of the animation sequence. Both the left margin and width of the <p> element are configured so that it's drawn from the correct edge of the browser. The second keyframe occurs at 100% (i.e. the last moment of the animation sequence). The left margin and width of the <p> chemical element are configured so that, once finished its animation, the paragraph is flush against the left border of the content area.

Take a look at the lawmaking below.

                                              

p {

animation-elapsing: 3s;

animation-name: slidein;

}

@keyframes slidein {

from {

margin-left: 100%;

width: 300%;

}

to {

margin-left: 0%;

width: 100%;

}

}

<p>The Caterpillar and Alice looked at each other for some time in silence: at last the Caterpillar took the hookah out of its oral cavity, and addressed her in a languid, sleepy vox.</p>

paragraph animated with CSS so it slides in from the right side of the browser window

Let'due south say we desire the <p> element to do something betwixt the start and terminate of the blitheness. Nosotros might, for example, add another keyframe so that the font size of the paragraph increases as it moves from right to left and then decreases dorsum to its original size by the end of the sequence.

In that case, the lawmaking will wait similar this:

                                              

p {

animation-elapsing: 3s;

animation-name: slidein;

}

@keyframes slidein {

from {

margin-left: 100%;

width: 300%;

}

75% {

font-size: 300%;

margin-left: 25%;

width: 150%;

}

to {

margin-left: 0%;

width: 100%;

}

}

<p>The Caterpillar and Alice looked at each other for some fourth dimension in silence: at final the Caterpillar took the hookah out of its mouth, and addressed her in a languid, sleepy vocalisation.</p>

The animation would now wait like the following.

paragraph animated with CSS to increase as it moves from right to left and then decreases back to its original size by the end of the sequence

With a firmer grasp of keyframes, we tin can at present turn our attention to the 2nd part that makes up CSS animations: blitheness properties.

Step 2: Define your animation-proper name and animation-duration backdrop.

Animation properties assign the keyframes to a specific chemical element and define how it is animated.

Y'all may take noticed that the code snippets above included the following two properties:

  • blitheness-duration
  • blitheness-name

These 2 properties are required for any animation to take effect. Nosotros'll briefly discuss these below.

Blitheness Proper noun

The blitheness-name property specifies the name of the keyframe. That'due south why in the examples above the value of the animation-proper name property — slidein — matched the name after @keyframes.

When naming your animation, you lot can employ messages a to z, numbers 0 to 9, underscores, and dashes.

If you have multiple keyframes describing the animations to apply to an element, then yous'll need to define multiple values for the blitheness-proper name belongings. You can divide these with a space and comma.

Animation Duration

The animation-elapsing property specifies the length of time of the animation sequence. While the animation could play on loop forever, it should take nevertheless many seconds or milliseconds are specified in the animation-duration property to consummate one bike.

The property can exist defined with zero or whatsoever positive value. Negative values are invalid. Below are some examples.

CSS animation-duration property set to three different values

Source

Step 3: Define other blitheness properties you need.

In addition to the animation-name and animation-duration properties, there are other animation backdrop you can employ to create more circuitous and custom animations. Let's ascertain each beneath.

Animation Timing

The animation-timing function sets the pace of the animation. To specify the timing of your animation, you can use the predefined values ease, linear, ease-in, ease-out, and ease-in-out. You lot can also create custom values using the cubic-bezier curve for more advanced timing options.

CSS Animation Easing

If no other value is assigned, the function volition be set at ease by default. Ease starts out slow, speeds upwards, and then slows downwards. Below is an instance.

circles with CSS animation-timing property set to ease

Source

Set at linear, the animation has the same speed from start to finish. With ease-in, the animation has a slow start. With ease-out, it has a slow end. Ease-in-out means the animation has both a slow offset and a deadening end.

Animation Filibuster

Using the blitheness-delay function, you tin can specify when the blitheness starts. Milliseconds and seconds are allowed, every bit are positive and negative values. A positive value volition delay the animation sequence whereas a negative value will outset the animation immediately, as if that amount of time has already gone by.

If y'all set up the value at 2s, for example, and then the animation will kickoff 2 seconds afterwards it is loaded. If y'all gear up the value at -2s, then the blitheness will kickoff ii seconds into the blitheness bike.

In the example below, a negative animation delay causes each circle to begin immediately at a unlike state in the animation cycle.

circles with negative animation delay set in CSS

Source

Animation Iteration Count

The animation-iteration-count property specifies the number of times that the animation volition play. You can utilize a number value to have information technology repeat a certain number of times.

You lot can fix information technology to initial to apply the default value (1), which means the animation will play through its sequence once. You can ready it to inherit to use the aforementioned value equally its parent element. Or you lot can set it to infinite to have it repeat indefinitely. Any CSS animation with its animation-iteration-count gear up to infinite is considered a CSS loop blitheness.

Take a expect at the demo below which shows three versions of the aforementioned blitheness, each with their animation-iteration-count property set at different values.

three cubes with CSS animation-iteration-count property set to 1, 2, and infinite

Source

Animation Direction

The animation-direction holding defines the direction of the animation. If you use the normal or default value, then the animation volition play forward. If you lot employ reverse, information technology will play backwards.

To have the animation reverse directions every bike, you can use the alternating value (the blitheness will play forwards commencement, then backwards) or the alternate-reverse (the animation volition play backwards outset, and then forwards).

Take a await at the demo showing each direction below.

four cubes with CSS animation-direction property set to normal, reverse, alternate, alternate-reverse

Source

Animation Fill Fashion

Using the blitheness-fill-mode office, you tin have the animation styles practical before or later on the blitheness plays.

There are four possible values you tin set this function to:

  1. If you lot set the belongings value to normal, then styles will only be applied to the animated element when it's playing.
  2. If you set it to forrard, then the blithe element will retain its style values defined by the terminal keyframe.
  3. If you set it to backwards, and so the element volition accept on the mode values defined by the outset keyframe before it begins playing.
  4. If you set it to both, the animation's style values volition be applied before and subsequently the animation plays.

Below is an example of an animation with its blitheness-fill-mode property set to forwards and the default value (normal).

two buttons with CSS animation-fill-mode property set to forwards and normal

Source

Blitheness Play State

With the blitheness-play-land holding, yous tin can break and resume the animation sequence. By default, this holding is set to running but you tin set the holding value to paused. Resuming a paused animation will play the animation from where it was paused, instead of starting over.

ball with CSS animation-play-state property set to paused

Source

Now that yous accept a better understanding of the dissimilar parts that make up an animation, you can create your own from scratch — or use a tool to help simplify the process.

CSS Animation Generator

A CSS animation generator can help simplify — and fifty-fifty automate — parts of the process of creating CSS animations. Using one will still crave some familiarity with keyframes and blitheness backdrop — but it volition reduce the complexity and require you lot to write less code.

Let'south take a look at the sleekest and easiest-to-use options.

Animista

CSS animation generator: Animista

Animista is a free application that allows you to customize pre-designed CSS animations. You can click on an animation type at the superlative of the screen (this will be your animation name), then specify all the blitheness sub-properties in the left sidebar. Most are drop-down menus to brand customizing your animation every bit easy as possible. When yous're fix, you can click the Generate Code icon and paste it into your web pages or projects.

CSS Animations Generator

css animation generator: css animations generator by web code tools

Similar to Animista, CSS Animations Generator allows you to customize the animation sub-properties for an blithe chemical element (just not the keyframes). When y'all're set up, you can re-create the code for the animated chemical element and @keyframes at-dominion and paste information technology into your web pages or projects.

Keyframes App

CSS animation generator: Keyframes appDesigned to look and function similar video-editing software, Keyframes is another costless awarding that allows y'all to create basic or complex keyframe animations with a visual timeline editor. You can add "steps" using the timeline at the bottom of the screen and define dissimilar animatable properties in the right sidebar — these will be your keyframes. You can also alter the duration, iteration count, and other sub-properties at the bottom of the screen. Then when you're ready, you can click the Get CSS push button and paste that lawmaking into your web pages or projects.

Gear up to create CSS animations from scratch or with one of the generators above? In that case, you may come across some issues. Let'due south look at some ways to troubleshoot if your animations aren't working every bit yous expect.

CSS Animation Not Working

Beginner developers and experienced ones may come across issues when creating CSS animations If yours isn't working at all or every bit yous intended, endeavour checking for these common issues.

ane. The animation-name holding isn't defined.

The animation-name holding is required. Otherwise, the animation won't render.

ii. The animation-elapsing property isn't divers.

The blitheness-duration holding must also be set.Otherwise, the default value is prepare to zero seconds so the animation won't render.

three. No @keyframes at-dominion is defined.

Animations are just executed when animation properties are applied, and then they require explicit values for the backdrop being animated. These values are specified using keyframes. If these are non specified in a @keyframes at-rule, and so the animation will not occur.

iv. The name of your @keyframes at-rule doesn't match the name of your animation.

The name of the @keyframes at-dominion must match the value of the blitheness-proper noun belongings. Otherwise, the browser won't be able to match the blitheness with its keyframes announcement and the animation won't render.

five. The blitheness-fill-mode property is not set up.

By default, CSS animations revert an element back to its pre-animated country once the animation cycle finishes. This can make the animation look broken. To avoid this, yous tin define the blitheness-fill-mode.

6. The CSS property you're attempting to animate isn't animatable.

Some CSS backdrop aren't animatable, which means they can't be used in animations (or transitions). Bank check out our listing of animatable CSS backdrop for the property y'all're trying to animate. If it'south not on there, you'll demand to utilize another CSS property to achieve a similar effect.

7. CSS animations are not supported on your browser version.

If your CSS animation isn't working, the problem might be your browser and not your code. While CSS animations work on nigh modern mobile and desktop browsers, older browsers or older versions of browsers don't. In that case, you'll demand to switch or update your browser.

viii. Values for the CSS shorthand belongings are in the wrong social club.

CSS shorthand is platonic for writing cleaner CSS — only information technology tin be more than difficult to write since the order of values matters. In that location'due south no strict order for every single sub-belongings, but some exercise matter. For example, the first "time" value will be assigned to the animation-duration holding and the second will exist assigned to the blitheness-delay property so you shouldn't mix up those values. Here is the typical order for the values for the autograph animation property: animation-name, elapsing, timing-function, delay, iteration-count, direction, make full-way, play-state.

For a complete listing of reasons your animations may not be working at all or as you intended (plus examples!), check out CSS Animations Not Working? Attempt These Fixes.

Now that we know how to create CSS animations from scratch or with a generator and how to troubleshoot whatever issues, let'due south look at some examples for inspiration.

one. 7up Lemon Lemon

In 2017, PepsiCo released a new drink called 7up Lemon Lemon. To promote the premium sparkling lemonade, the 7up site was redesigned using CSS blitheness. Combining the fade-in and wobble blitheness, developers fabricated the folio fizz like the beverage. The page has since been redesigned.

7up Lemon Lemon CSS animation example

2. 2016 Kikk Festival

Each yr, the agency dogstudio rebrands the Kikk Festival's website. In 2016, dogstudio redesigned the site using CSS blitheness to create paradigm and page glitches that represented the festival's theme of "interference."

2016 Kikk Festival CSS animation example

3. Apple iPad Pro

To promote the iPad Pro in 2019, Apple took an interesting spin on parallax scrolling. Scrolling horizontally instead of vertically, you could notice the text, images, and other visual elements moving around at different speeds. These CSS animations kept visitors engaged as they scrolled through the page to learn more about the product. The folio has since been redesigned.

Apple iPad Pro CSS animation example

4. In Pieces

Bryan James, a designer based in the UK, created an interactive exhibition called "Pieces" that profiles 30 endangered species. Using CSS animations, James designed the site to accept the same 30 pieces arranging and rearranging themselves into the shape of each animal as yous whorl through the showroom.

CSS animation on scroll

5. Jeans for Refugees

Jeans for Refugees is a global fundraising initiative that artist Johny Darde created to aid refugees around the world. The agency Lilo created the Jeans for Refugees site pro bono to back up the initiative. The bureau used CSS animations to brand elements that look like pigment strokes form and re-form into words on the page.

Jean for Refugees CSS animation example

6. Chekhov Is Alive

Using color and fade-in, among many other CSS animations, developers were able to bring thirty of Anton Chekhov's virtually famous characters to life. Originally created so that users could audience to play a part in a live Google broadcast of Chekhov's stories in 2015, this personality test let people discover out which Chekhov character they virtually closely resembled. Information technology'south no longer live.

Chekhov is alive css animation example

vii. MY / STATIC / Cocky

The homepage of John Iacoviello's personal portfolio is a testament to his skills as an laurels-winning developer. Although the glitch effect applied to the central object (is it a stereo system? Hard drive?) is the nearly obvious, you might likewise notice that the bounce and rotate animation are beingness used.

MY / STATIC / SELF portfolio CSS animation example

8. Portion

Portion is a premier online marketplace for artists and collectors to connect and hands and securely sell or buy art using Blockchain applied science. While the entire website'due south blueprint demonstrates the company's purpose and values — take the transparent auction house on the homepage, for example — you get this impression right away thanks to the CSS loading animation. This animation of Portion's brand logo — a clear and simple construction of connected lines that looks similar an inverse crown — invokes the ideas of regality, connectedness, and blockchain.

CSS infinite loading animation example-1

9. Travelshift

As a travel website, Travelshift has a unique navigation system with horizontal scrolling, several transitions, and parallax sections. These animations and furnishings make the reader feel immersed in the images and so that they get a taste of the adventures they could take if they booked a trip with Travelshift.

Travelshift Parallax scrolling animation example

10. Soletanche Bachy

The Solentanche Bachy'south website showcases the construction project of a new metro station in Signapore. CSS slide-in and rotate animations, amongst other effects, turn the website into an interactive pattern for those who are interested in the location, design, and engineering science of this station.

CSS slide-in and rotate animations example on Soletanche Bachy

11. Ember Business firm

When Ember House redesigned their site two years ago, they wanted to bear witness that they were unlike from other fiscal consulting companies because they cared nearly their clients' well-being. To convey this idea, the Behance agency focused on the idea of an ember as the starting bespeak of a good campfire. Using a combination of slide-in, moving ridge, and rotation animations, they made it look like embers were floating across the screen. They also used CSS text animation to underline central parts of the messaging like "feel skillful" and "warm up to your wealth."

CSS text animation example on Ember House

12. Locomotive

Locomotive is a Canadian-based agency that aims to push new ideas and stand up out among other agencies without taking themselves too seriously. This is embodied by its employ of CSS animations, particularly the bounce animation, beyond its website. The acme of its web pages wait almost like text written on lined paper — only with a playful twist. The lines bounce to continue readers engaged equally the rest of the content on the page loads.

CSS bounce animation example on Locomotive website

13. Volcan

Several scrolling effects keep visitors engaged on the Volcan site. One is a CSS text animation triggered as the reader scrolls down the page. It looks as if the paragraph is being shaken similar a towel, and then laid flat on the page.

CSS Text animation example on Volcan

14. Wide Centre

Broad Eye is a artistic agency that works with changemakers and visionaries to create designs, branding, and digital products that will help them exercise the most expert. This combination of social activism and innovative design is demonstrated past the text animation on its homepage. The text first slides in from the left. Then new words slide in and out to consummate the judgement. The effect is engaging, emotional, and center-communicable — the three e's that Broad Middle hope to capture in every digital experience.

CSS slide-in animation example on Wide Eye website

15. Annatwelve

Annatwelve'due south website showcases its drove of nine luxury fragrances designed for those who are sick of what'southward "obvious" and want "something more." To appeal to this demographic, the site has a unique horizontal navigation menu with each of the fragrances equally a main navigation selection rotated xc degrees to the left. When you lot hover over ane of the fragrances, the others fade from solid white to a much more transparent white. As a effect of these hover and colour animations, it virtually looks like a spotlight is shining on the fragrance name you lot're hovering over.

Annatwelve hover animation example-min

Now that nosotros've checked out some examples of CSS animations on existent websites, you'll be able to place other examples on the internet. To avoid a mutual misconception, let's differentiate between CSS transitions and animations.

CSS Transition vs. Animation

Though oftentimes grouped together, CSS animations are different from CSS transitions. One major difference is that CSS transitions require a trigger — similar a company clicking on an element, for instance. Animations, on the other manus, don't require triggering. Past default, an blitheness volition automatically begin its sequence when the page loads. (Information technology's of import to note that some developers will utilise jQuery or implement another mode of triggering an animation, simply they don't demand to).

Another major departure is that transitions can only motility from an initial state to a final state. You cannot specify any intermediate points similar you lot can with an animation.

Nor can y'all have a transition loop or echo backwards. That'due south because, while animations have the blitheness-iteration-count and animation-management property, transitions don't have properties that specify how many times they tin can run or what direction they can run in. Equally a effect, a transition runs merely one time when triggered.

At present that we have a better understanding of what CSS animation is (and is not), let's take a look at a specific subset chosen 3D transforms.

CSS 3D Blitheness

CSS 3D animation — unremarkably referred to as 3D transforms — opens upwardly a new realm of graphic design. With 3D transforms, front-end developers tin add a new dimension to traditional websites to heighten their design.

For example, consider the interpret function. Translate moves an element from point A to B. In second, you can use interpret to move an element forth the horizontal X-centrality or the vertical Y-axis. In the example beneath, the black ball moves across the Ten-axis.

ball animated with CSS translate function in 2D

Source

Using a 3D transform function, nevertheless, you can position an element along the Z-axis. Since this centrality runs front to back in 3D space, you can move an element closer to the viewer and so farther away. Accept a look at the instance beneath.

cube animated with 3d transform CSS function

Source

Every bit with any animations, 3D transforms should be more than than just centre candy. When used wisely, they tin solve interface challenges and enhance the visitor experience. When used without strategic purpose, they can be distracting and clutter your interface.

Bringing Your Site to Life

From subtle transitions to a completely illustrated site, you can find animations on most websites today. Making 3D effects and interactive details part of your web design strategy tin improve the visitor experience and differentiate your site from competitors.

Editor'south note: This mail was originally published in March 2020 and has been updated for comprehensiveness.

New Call-to-action

css introduction

Originally published Sep 21, 2021 7:00:00 AM, updated Apr 20 2022

Source: https://blog.hubspot.com/website/css-animation

Posted by: allenmignobt.blogspot.com

0 Response to "How To Make A Css Animation Repeat"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel