将此css运动模糊效果反转为垂直

时间:2015-08-03 14:49:27

标签: html css css3 css-transitions css-animations

我有这个代码,允许对象运动模糊并排,但我希望它垂直运动蓝色,所以它从上到下然后再向上。你能帮帮我吗?

http://jsfiddle.net/db8gr4y6/

psexec -?
  #outer {
    position: relative;
    margin: 10px;
  }
  #mb {
    position: absolute;
    left: 0;
    font-size: 2em;
    font-weight: bold;
    padding: 0.2em 1em;
    color: #fff;
    background-color: #600;
    border: 0.2em solid #c00;
    border-radius: 8px;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0);
    box-shadow: 0 0 2px rgba(200, 0, 0, 0);
    -webkit-animation: motionblur 4s ease-in-out infinite;
    animation: motionblur 4s ease-in-out infinite;
  }
  @-webkit-keyframes motionblur {
    0% {
      left: 0;
      text-shadow: 0 0 0 rgba(255, 255, 255, 0);
      box-shadow: 0 0 0 rgba(200, 0, 0, 0);
    }
    5% {
      left: 0;
      -webkit-transform-origin: 0 0;
      -webkit-transform: scaleX(0.85);
    }
    25% {
      text-shadow: -5px 0 5px rgba(255, 255, 255, 1);
      box-shadow: -15px 0 10px -5px rgba(200, 0, 0, 0.5);
      -webkit-transform: scaleX(1.1) skewX(-4deg);
    }
    50% {
      left: 300px;
      text-shadow: 0 0 0 rgba(255, 255, 255, 0);
      box-shadow: 0 0 0 rgba(200, 0, 0, 0);
      -webkit-transform: scaleX(1) skewX(0deg);
    }
    55% {
      left: 300px;
      -webkit-transform-origin: 100% 0;
      -webkit-transform: scaleX(0.85);
    }
    75% {
      text-shadow: 5px 0 5px rgba(255, 255, 255, 1);
      box-shadow: 15px 0 10px -5px rgba(200, 0, 0, 0.5);
      -webkit-transform: scaleX(1.1) skewX(4deg);
    }
    100% {
      left: 0px;
      text-shadow: 0 0 0 rgba(255, 255, 255, 0);
      box-shadow: 0 0 0 rgba(200, 0, 0, 0);
      -webkit-transform: scaleX(1) skewX(0deg);
    }
  }
  @keyframes motionblur {
    0% {
      left: 0;
      text-shadow: 0 0 0 rgba(255, 255, 255, 0);
      box-shadow: 0 0 0 rgba(200, 0, 0, 0);
    }
    5% {
      left: 0;
      transform-origin: 0 0;
      transform: scaleX(0.85);
    }
    25% {
      text-shadow: -5px 0 5px rgba(255, 255, 255, 1);
      box-shadow: -15px 0 10px -5px rgba(200, 0, 0, 0.5);
      transform: scaleX(1.1) skewX(-4deg);
    }
    50% {
      left: 300px;
      text-shadow: 0 0 0 rgba(255, 255, 255, 0);
      box-shadow: 0 0 0 rgba(200, 0, 0, 0);
      transform: scaleX(1) skewX(0deg);
    }
    55% {
      left: 300px;
      transform-origin: 100% 0;
      transform: scaleX(0.85);
    }
    75% {
      text-shadow: 5px 0 5px rgba(255, 255, 255, 1);
      box-shadow: 15px 0 10px -5px rgba(200, 0, 0, 0.5);
      transform: scaleX(1.1) skewX(4deg);
    }
    100% {
      left: 0px;
      text-shadow: 0 0 0 rgba(255, 255, 255, 0);
      box-shadow: 0 0 0 rgba(200, 0, 0, 0);
      transform: scaleX(1) skewX(0deg);
    }

1 个答案:

答案 0 :(得分:5)

尝试此操作以反转动画。

只需将所有left属性替换为Top

即可

X的所有变换属性,ScaleXSkewXSkewX SkewY

#outer {
  position: relative;
  margin: 10px;
}
#mb {
  position: absolute;
  left: 0;
  font-size: 2em;
  font-weight: bold;
  padding: 0.2em 1em;
  color: #fff;
  background-color: #600;
  border: 0.2em solid #c00;
  border-radius: 8px;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0);
  box-shadow: 0 0 2px rgba(200, 0, 0, 0);
  -webkit-animation: motionblur 4s ease-in-out infinite;
  animation: motionblur 4s ease-in-out infinite;
}
@-webkit-keyframes motionblur {
  0% {
    top: 0;
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    box-shadow: 0 0 0 rgba(200, 0, 0, 0);
  }
  5% {
    top: 0;
    -webkit-transform-origin: 0 0;
    -webkit-transform: scaleY(0.85);
  }
  25% {
    text-shadow: -5px 0 5px rgba(255, 255, 255, 1);
    box-shadow: -15px 0 10px -5px rgba(200, 0, 0, 0.5);
    -webkit-transform: scaleY(1.1) skewY(-4deg);
  }
  50% {
    top: 300px;
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    box-shadow: 0 0 0 rgba(200, 0, 0, 0);
    -webkit-transform: scaleY(1) skewY(0deg);
  }
  55% {
    left: 300px;
    -webkit-transform-origin: 100% 0;
    -webkit-transform: scaleY(0.85);
  }
  75% {
    text-shadow: 5px 0 5px rgba(255, 255, 255, 1);
    box-shadow: 15px 0 10px -5px rgba(200, 0, 0, 0.5);
    -webkit-transform: scaleY(1.1) skewY(4deg);
  }
  100% {
    top: 0px;
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    box-shadow: 0 0 0 rgba(200, 0, 0, 0);
    -webkit-transform: scaleY(1) skewY(0deg);
  }
}
@keyframes motionblur {
  0% {
    top: 0;
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    box-shadow: 0 0 0 rgba(200, 0, 0, 0);
  }
  5% {
    top: 0;
    -webkit-transform-origin: 0 0;
    -webkit-transform: scaleY(0.85);
  }
  25% {
    text-shadow: -5px 0 5px rgba(255, 255, 255, 1);
    box-shadow: -15px 0 10px -5px rgba(200, 0, 0, 0.5);
    -webkit-transform: scaleY(1.1) skewY(-4deg);
  }
  50% {
    top: 300px;
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    box-shadow: 0 0 0 rgba(200, 0, 0, 0);
    -webkit-transform: scaleY(1) skewY(0deg);
  }
  55% {
    top: 300px;
    -webkit-transform-origin: 100% 0;
    -webkit-transform: scaleY(0.85);
  }
  75% {
    text-shadow: 5px 0 5px rgba(255, 255, 255, 1);
    box-shadow: 15px 0 10px -5px rgba(200, 0, 0, 0.5);
    -webkit-transform: scaleY(1.1) skewY(4deg);
  }
  100% {
    top: 0px;
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    box-shadow: 0 0 0 rgba(200, 0, 0, 0);
    -webkit-transform: scaleY(1) skewY(0deg);
  }
<div id="outer">
  <div id="mb">Motion Blur</div>
</div>