Questions tagged [css-animations]

CSS animations make it possible to animate transitions from one CSS style configuration to another. CSS module describes 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.

CSS animations make it possible to animate transitions from one CSS style configuration to another. Animations consist of two components, a style describing the CSS animation and a set of keyframes that indicate the start and end states of the animation's style, as well as possible intermediate waypoints.

Properties

  • animation-delay

  • animation-direction

  • animation-duration

  • animation-iteration-count

  • animation-name

  • animation-play-state

  • animation-timing-function

  • animation-fill-mode

Animations are similar to in that they change the presentational value of CSS properties over time. The principal difference is that while transitions trigger implicitly when property values change, animations are explicitly executed when the animation properties are applied.

Example

p {
  animation-duration: 3s;
  animation-name: slidein;
}
@keyframes slidein {
  from {
    margin-left: 100%;
    width: 300%; 
  }

  to {
    margin-left: 0%;
    width: 100%;
  }
}

References

7488 questions
103
votes
2 answers

How to window.scrollTo() with a smooth effect

I can scroll to 200px using the following btn.addEventListener("click", function(){ window.scrollTo(0,200); }) But I want a smooth scroll effect. How do I do this?
KolaCaine
  • 2,037
  • 5
  • 19
  • 31
98
votes
3 answers

Is there a callback on completion of a CSS3 animation?

Is there any way to implement a callback function in case of css3 animation? In case of Javascript animation its possible but not finding any way to do it in css3. One way I could see is to execute callback after the animation duration but that…
alter
  • 4,320
  • 7
  • 31
  • 36
92
votes
3 answers

How to prevent css3 animation reset when finished?

I write a css3 animation and it is only performed once. The animation works well, but it will reset when the animation finished. How can I avoid this, I want to keep the result instead of reset it. $(function() { …
SPG
  • 6,109
  • 14
  • 48
  • 79
86
votes
9 answers
83
votes
9 answers

How to prevent a CSS keyframe animation from running on page load?

I have a div in which I animate the content: #container { position: relative; width: 100px; height: 100px; border-style: inset; } #content { visibility: hidden; -webkit-animation: animDown 1s ease; position: absolute; top: 100px; …
Szabolcs
  • 1,463
  • 2
  • 12
  • 20
78
votes
4 answers

Rotating globe in CSS

I am creating a rotating earth effect in CSS. I have created the globe in CSS : body { background-color: #111; } #earth { width: 300px; height: 300px; background:…
user4420272
73
votes
7 answers

Is it possible to animate Flexbox inserts & removes?

When I remove an item from a flexbox, the remaining items "snap" into their new positions immediately rather than animating. Conceptually, since the items are changing their positions, I would expect the transitions to apply. I have set the…
mmaclaurin
  • 1,412
  • 1
  • 13
  • 18
72
votes
8 answers

How can I create pure CSS 3-dimensional spheres?

tl;dr: I would like to create an actual 3d sphere with CSS - not just an illusion Note: some of the snippet examples are not responsive. Please use full screen. With pure CSS you can create and animate a 3d cube like so: #cube-wrapper { …
I haz kode
  • 1,587
  • 3
  • 19
  • 39
72
votes
7 answers

Animating max-height with CSS transitions

I want to create an expand/collapse animation that's powered only by classnames (javascript is used to toggle the classnames). I'm giving one class max-height: 4em; overflow: hidden; and the other max-height: 255em; (I also tried the value none,…
Madd0g
  • 3,841
  • 5
  • 37
  • 59
71
votes
3 answers

CSS3 - Transition on DOM Removal

Using keyframes, it is possible to animate an element as soon as it is inserted into the DOM. Here's some sample CSS: @-moz-keyframes fadeIn { from {opacity:0;} to {opacity:1;} } @-webkit-keyframes fadeIn { from {opacity:0;} to…
Steve
  • 2,023
  • 3
  • 17
  • 25
71
votes
5 answers

Webkit CSS Animation issue - persisting the end state of the animation?

Given the following CSS3 animation....