简体   繁体   English

Animate.css库与等效的jQuery代码一起在IE上工作

[英]Animate.css library to equivalent jquery code to work on IE

I have implemented a successful slider using ( Animate.CSS ) , but it's using CSS 3 and it doesn't work well or at all in IE , So I thought we might use JavaScript/Jquery to come up with animations just like those provided by Animate.CSS... 我已经使用( Animate.CSS )实现了一个成功的滑块,但是它使用的是CSS 3,并且在IE中效果不佳或根本不起作用,所以我想我们可能会使用JavaScript / Jquery来制作动画,就像由Animate.CSS ...

How can I implment this? 我该如何实施?

Animate.css uses @keyframe that only works from IE10+. Animate.css使用仅在IE10 +中有效的@keyframe transition CSS property does not work either. transition CSS属性也不起作用。

http://caniuse.com/#search=keyframe http://caniuse.com/#search=keyframe

http://caniuse.com/#search=transition http://caniuse.com/#search=transition

You will have to use jQuery animate() method. 您将必须使用jQuery animate()方法。

Link to the docs: 链接到文档:

http://api.jquery.com/animate/ http://api.jquery.com/animate/

Animations made with @keyframes can look a lot better because you set each frame of the animation. 使用@keyframes制作的动画看起来更好,因为您设置了动画的每一帧。 But it won't work in IE9 or lower, there is no way. 但是它无法在IE9或更低版本中使用,这是不可能的。 You should use jQuery animate() method. 您应该使用jQuery animate()方法。

See a good example: 看到一个很好的例子:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>animate demo</title>
  <style>
  div {
    background-color: #bca;
    width: 200px;
    height: 1.1em;
    text-align: center;
    border: 2px solid green;
    margin: 3px;
    font-size: 14px;
  }
  button {
    font-size: 14px;
  }
  </style>
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

<button id="go1">&raquo; Animate Block1</button>
<button id="go2">&raquo; Animate Block2</button>
<button id="go3">&raquo; Animate Both</button>
<button id="go4">&raquo; Reset</button>
<div id="block1">Block1</div>
<div id="block2">Block2</div>

<script>
$( "#go1" ).click(function() {
  $( "#block1" )
    .animate({
      width: "90%"
    }, {
      queue: false,
      duration: 3000
    })
    .animate({ fontSize: "24px" }, 1500 )
    .animate({ borderRightWidth: "15px" }, 1500 );
});

$( "#go2" ).click(function() {
  $( "#block2" )
    .animate({ width: "90%" }, 1000 )
    .animate({ fontSize: "24px" }, 1000 )
    .animate({ borderLeftWidth: "15px" }, 1000 );
});

$( "#go3" ).click(function() {
  $( "#go1" ).add( "#go2" ).click();
});

$( "#go4" ).click(function() {
  $( "div" ).css({
    width: "",
    fontSize: "",
    borderWidth: ""
  });
});
</script>

</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM