Table of Contents
Use Animate.css animation
Second custom Animate.css animation
3 Using JavaScript to control animations
Home Web Front-end HTML Tutorial CSS uses Animate.css to create animation effects_html/css_WEB-ITnose

CSS uses Animate.css to create animation effects_html/css_WEB-ITnose

Jun 24, 2016 am 11:43 AM

Use Animate.css animation

//Introduce external CSS resources through @import;

//Introduce online images and JS files;

// Generate different types of CSS3 animations by changing the CSS class name;


 
Copy after login
Copy after login

 1 <!DOCTYPE html> 2 <html lang="en"> 3     <head> 4         <meta charset="utf-8"> 5     </head> 6     <style> 7         /* Animate.css GitHub地址:https://github.com/daneden/animate.css */ 8         /* Animate.css 演示地址:https://daneden.github.io/animate.css/ */ 9 10         @import url("http://cdn.gbtags.com/animate.css/3.1.1/animate.min.css");11         body {12             background: #cfcfcf;13         }14         img {15             position: absolute;16             left: 50%;17             top:50%;18             margin-left: -100px;19             margin-top: -100px;20             width:200px;21             height:200px;22         }23 24     </style>25     <body>26         <img src="http://www.gbtags.com/gb/networks/uploadimg/074627f0-0a62-4176-aa85-06a4364deeab.png" alt="">27     </body>28     <script src="http://cdn.gbtags.com/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>29     <script>30         function rock (x) {                             // 定义事件函数;31             $('img').not('.center')32                     .addClass(x + ' animated')          // 添加CSS类名;33                     .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'34                     ,function(){35                         $(this).removeClass();36                     });37         };38 39         $(document).ready(function(){40             rock("rubberBand infinite");                // 添加CSS类名生成相应的动态效果;41             setTimeout(function(){window.lcation.href = "http://www.kiklink.com"},6000);42             // 设置时间跳转;43         });44     </script>45 </html>
Copy after login

 
Copy after login
Copy after login

Second custom Animate.css animation

// You can use the animate.css code as a basis to write custom animation effects;

 1 @keyframes bounce {                     /*通过@keyframes规则,创建bounce动画;*/ 2     0%,20%,50%,80%,100% { 3         transform:translateY(0); 4     } 5     40% { 6         transform:translateY(-30px); 7     } 8     60% { 9         transform:translateY(-15px);10     }11 }12 .bounce {13     animation-name:bounce;              /*调用bounce动画;*/14 }15 .animated {16     animation-duration:3s;              /*一个动画周期的时长;*/17     animation-fill-mode:both;           /*指定动画执行之前之后的样式;*/18 }19 .animated.infinite {20     animation-iteration-count:infinite; /*定义动画播放的次数;(n次/infinite无限次);*/21 }
Copy after login

1 <img class="animated bounce infinite" src="http://www.gbtags.com/gb/laitu/150x150" alt="">
Copy after login

3 Using JavaScript to control animations

1 $('img').click(function(){              // 给Img元素绑定点击事件;2     var $this = $(this);                // 鼠标点击之后添加相应的动画类名; 3     $this.addClass('animated bounce').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend',function(){4                                         //<strong> 当-webkit-animation动画结束之后会有一个webkitAnimationEnd事件;</strong>5                                         //<strong> 当one()方法监听到webkitAnimationEnd事件之后才执行function函数;one()方法只能执行一次;</strong>6         $this.removeClass();            // 清除相应的动画类名;7     })8 });
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles