简体   繁体   中英

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...

How can I implment this?

Animate.css uses @keyframe that only works from IE10+. transition CSS property does not work either.

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

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

You will have to use jQuery animate() method.

Link to the docs:

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

Animations made with @keyframes can look a lot better because you set each frame of the animation. But it won't work in IE9 or lower, there is no way. You should use jQuery animate() method.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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