shadeed9
shadeed9

Reputation: 1836

SVG animation using CSS doesn't work

I'm new to SVG and trying to animate the two circles in this pin

The animation doesn't work and I think that there is problem with my code.

SVG

<svg xmlns="http://www.w3.org/2000/svg">
   <rect height="60" width="100" fill="#B32317" rx="10" ry="10"></rect>
  <g class="eyes">
      <circle class="c1" cx="25" cy="20" r="10" fill="#fff"></circle>
      <circle class="c1" cx="75" cy="20" r="10" fill="#fff"></circle>
      <circle cx="25" cy="20" r="7" fill="#B32317"></circle>
      <circle cx="75" cy="20" r="7" fill="#B32317"></circle>
  </g>
</svg>

CSS

.c1 {
  -webkit-animation-name: scaleme;
  -webkit-animation-duration: 3s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-direction: alternate;

  animation-name: scaleme;
  animation-duration: 3s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  animation-direction: alternate;
}

@-webkit-keyframes scaleme {
  transform: scale(1.1) translate(5px,0);
}

Any help please?

Thanks,

Upvotes: 0

Views: 896

Answers (2)

gooor
gooor

Reputation: 111

@keyframes scaleme {
  0% {
    transform: scale(1.1) translate(5px,0);    
  },
  100% {
    transform: scale(1.0) translate(0px,0);
  }

}

Upvotes: 0

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123428

Your keyframes should be written like so

@-webkit-keyframes scaleme {
  0% { transform: scale(1) translate(0,0); }
  100% { transform: scale(1.1) translate(5px,0); }
}

@keyframes scaleme {
  0% { transform: scale(1) translate(0,0); }
  100% { transform: scale(1.1) translate(5px,0); }
}

Fork: http://codepen.io/anon/pen/HaBmd

Upvotes: 1

Related Questions