css animation rotate and translate doesn't work together [duplicate]

橙三吉。 提交于 2019-12-10 11:42:05

问题


I'm trying out the css animation using @keyframes, however the css Transform rotate and translate properties aren't working together.

Please advise on what has gone wrong here. Thanks!!

You can check the code on codepen: http://codepen.io/anon/pen/XdzwZB

following is my @keyframes code:

@keyframes slideIn {
  0%, 100% {
    transform: translate(10px);
    transform: rotate(0deg);
    color: red;
  }
  25% {
    transform: translate(125px);
    transform: rotate(360deg);
    color: green;
  }
}

回答1:


The correct way to apply multiple transforms is to simply place them all in one transform property, with each transform separated by a space:

@keyframes slideIn {
  0%, 100% {
    transform: translate(10px) rotate(0deg);
    color: red;
  }
  25% {
    transform: translate(125px) rotate(360deg);
    color: green;
  }
}

Updated codepen



来源:https://stackoverflow.com/questions/36455370/css-animation-rotate-and-translate-doesnt-work-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!