在视差图像上添加关键帧

时间:2018-10-02 13:13:43

标签: jquery html css animation parallax

我有一个使用视差效果的图像。 当我加载页面时,此图像带有关键帧。 问题是,当我开始滚动时,背景图像的位置会像故障一样移动。 我该如何解决?

HERE'S MY JSFIDDLE

HTML:     

<div class="image scene_element scene_element--fadeinupimage"> </div>

</div>
<script src="https://raw.githubusercontent.com/nk-o/jarallax/master/jarallax/jarallax.js"></script>

CSS:

body {
  height:1000px;
}

.image {
  height:600px;
  width:400px;
  background-image:url("https://www.catster.com/wp-content/uploads/2017/08/A-fluffy-cat-looking-funny-surprised-or-concerned.jpg");
  margin:50px;
  position: relative;
  background-repeat: no-repeat;
    background-position: 50% 50%;
  background-size: cover;
}

@keyframes fadeInUpImage {
  0% {
   /* transform: translate3d(0, 50%, 0);*/
    opacity:0;
    transform: translateY(50%);
  }

  100% {
    opacity:1;
    transform: translateY(0px);
  }
}

.m-scene .scene_element {
  -webkit-animation-duration: 0.80s;
  animation-duration: 0.80s;
  -webkit-transition-timing-function: ease-in;
  transition-timing-function: ease-in;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both; }

.m-scene .scene_element--fadeinupimage {
  -webkit-animation-name: fadeInUpImage;
  animation-name: fadeInUpImage; }

JS:

See the JSDIFFLE

0 个答案:

没有答案