Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 animation with keyframes and background-size property not working in Chrome 51

I had a piece of code similar to the one in this example. There are basically some keyFrames (0% and 100%) which sets the background-size property to 100%, while the keyFrame 50% sets that property to 50%.

@keyframes imagebulger {
  0%,
  100% {
    background-size: 100% auto;
  }
  50% {
    background-size: 50% auto;
  }
}

div.hotspot {
  width: 200px;
  height: 100px;
  background-image: url("http://dummyimage.com/200x100/000/fff");
  background-repeat: no-repeat;
  animation: imagebulger 2s infinite !important;
}
<div class="hotspot"></div>

That example worked as expected (performing the transition) in Chrome < 51, Firefox, IE 11 and so on. However, after the Chrome update (51.0.2704.63) it does not work anymore. I tried in Windows computer and in Linux computer and same result.

Somebody with that issue found a workaround? Otherwise I will post directly as a Chrome bug

Related with the issue Background-size transitions in Chrome 51 - a bug or a feature?, seems like it works using the prefix property but not without it, which does not makes sense at all.

This version will work, however I was forced to set the prefix -webkit- to the normal keyframes which probably will make this animation not work in some other browsers. I don't think that is an accepted solution.

like image 396
Didac Montero Avatar asked Oct 19 '22 08:10

Didac Montero


People also ask

Why is my CSS animation not working?

CSS animations work on most modern mobile and desktop browsers. However, your animations may not work if you're using an older browser or a version of your browser that hasn't been updated in several years, simply due to lack of browser support.

Do CSS animations work on all browsers?

Note: All browsers support the animation property without vendor prefixes.

Does css3 use keyframe animation?

You can change as many CSS properties you want, as many times as you want. To use CSS animation, you must first specify some keyframes for the animation.

What is the standard syntax for animation in css3 keyframes?

The @keyframes rule specifies the animation code. The animation is created by gradually changing from one set of CSS styles to another. During the animation, you can change the set of CSS styles many times.


1 Answers

Workaround

Using both the standard background-size followed by -webkit-background-size, solves the problem (example).

div.hotspot {
  width: 200px;
  height: 100px;
  background-image: url("http://dummyimage.com/200x100/000/fff");
  background-repeat: no-repeat;
  animation: imagebulger 2s infinite;
}
@keyframes imagebulger {
  0%, 100% {
    background-size: 100% auto;
    -webkit-background-size: 100%;
  }
  50% {
    background-size: 50% auto;
    -webkit-background-size: 50%;
  }
}
<div class="hotspot"></div>
like image 198
misterManSam Avatar answered Oct 21 '22 02:10

misterManSam