JQuery animate and CSS3 are combined to achieve slow-moving Chase Effect. Source Code download is provided. jquerycss3

Source: Internet
Author: User

JQuery animate and CSS3 are combined to achieve slow-moving Chase Effect. Source Code download is provided. jquerycss3

Both CSS3 and jquery can achieve a slow chase effect. However, considering the compatibility of browsers, we recommend that you use the jquery animate method.

The following figure shows the implementation result:

Download demo source code

Reference file: jquery-1.11.1.min.js

Html

<div id="container"><div id="first"></div><div id="second"></div></div>

Jquery

var $first=$('#first');var $second=$('#second');(function(){move1();move2();})()function move1(){$first.animate({"left":220,"top": 0},400).animate({"left":220,"top":220},400).animate({"left":0,"top":220},400).animate({"left":0,"top":0},function(){move1();})}function move2(){$second.animate({"right":220,"bottom": 0},400).animate({"right":220,"bottom":220},400).animate({"right":0,"bottom":220},400).animate({"right":0,"bottom":0},function(){move2();})}

The above is a small series of jQuery animate and CSS3 combined to achieve the effect of slow-moving Chase, I hope to help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.