Animate.css简单使用

引入animate.css文件

1.网络引用 

<link rel="stylesheet" href="https://raw.githubusercontent.com/daneden/animate.css/master/animate.css">

2.下载css

https://daneden.github.io/animate.css/,下载并保存为css文件

使用方法

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <link rel="stylesheet" href="css/animate.css">
    <script type="text/javascript" src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <style type="text/css">
            * {
            margin: 0;
            padding: 0;
        }

        .modal_content {
            width: 500px;
            height: 500px;
            margin-left: 650px;
            background-color: rgba(44, 55, 84, 0.8);
            margin-top: 150px;
            border-radius: 25px;
            /*设置动画属性*/
			/*动画持续时间*/
            -webkit-animation-duration: 3s;
           /*动画延迟时间*/
            -webkit-animation-delay: 1s;
           /*动画执行次数*/
            animation-iteration-count: 1;  
        }

        @media screen and (max-width:1000px) {
            .modal_content {
                width: 300px;
                height: 500px;
                margin-left: -150px;
            }
        }
    </style>
    <script type="text/javascript">
        $(function () {
            //给div增加类型添加动画
			var modal_animate= $('.modal_content');
            // infinite 无限重复动画  animated 规定是一个动画  tada动画名称
           modal_animate.addClass('animated tada');
		   //动画完后执行的函数
           modal_animate.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                    console.log('hello world'); //动画完毕后才打印
		    //移除动画
                    modal_animate.removeClass('animated tada');
                    //添加动画
		    modal_animate.addClass('animated rotateIn');
                });
        });
    </script>
</head>

<body>
    <div class="modal_content">
        <h1 align="center">文字部分</h1>
    </div>
</body>

</html>
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Vue Animate.css 是一个 Vue.js 的插件,它可以让你轻松地在 Vue.js 应用程序中使用 Animate.css 动画库。使用 Vue Animate.css,你可以通过简单的指令来添加动画效果,而不需要编写任何 JavaScript 代码。下面是使用 Vue Animate.css 的步骤: 1. 安装 Vue Animate.css 插件: ``` npm install vue-animate-css ``` 2. 在 Vue.js 应用程序中引入 Vue Animate.css 插件: ``` import Vue from 'vue' import VueAnimateCss from 'vue-animate-css' Vue.use(VueAnimateCss) ``` 3. 在 Vue.js 组件中使用指令来添加动画效果: ``` <template> <div v-animate="'bounce'">Hello, world!</div> </template> ``` 在上面的例子中,我们使用 `v-animate` 指令来添加 `bounce` 动画效果。你可以在 Vue Animate.css 文档中找到更多可用的动画效果。 希望这个回答能够帮助你! ### 回答2: Vue animate.css是一款非常方便实现各种动画的工具。它是基于开源库animate.css开发而来,使得在Vue项目中使用动画效果变得更为便捷。 首先,在Vue项目中还需要安装vue-animate-css这个插件以便使用这款工具。可以使用npm包管理工具来安装它,输入以下命令然后等待安装完成。 npm install vue-animate-css --save 使用这个工具的方式通常有三种: 1. 以组件的方式使用: 在需要使用动画效果的组件内,引入vue-animate-css库并且设置样式class即可。例如: ``` <template> <div> <h1 :class="animatedClass">例子</h1> </div> </template> <script> import {hover, fadeIn} from 'vue-animate-css'; export default { data: () => ({ animatedClass: hover + ' ' + fadeIn }) } </script> ``` 2. 作为全局 mixin: 使用全局mixin方法后,在整个Vue项目内都可以方便地使用动画效果。比如: ``` import Vue from 'vue'; import {bounce} from 'vue-animate-css'; Vue.mixin({ methods: { bounce: bounce } }); ``` 在使用时只需要在需要使用效果的元素上添加样式类名即可。 3. 通过指令使用: 通过指令使用在有些情况下更为直观。在使用前需要先在Vue项目中引入animate.css库。比如: ``` import 'animate.css/animate.min.css'; import Vue from 'vue'; Vue.use({ install(Vue) { Vue.directive('animate', { inserted: (el, binding) => { el.addEventListener('animationend', () => { el.classList.remove(binding.value, 'animated'); }); el.classList.add('animated', binding.value); } }); } }); ``` 在使用指令的组件中,可以在需要使用动画效果的元素上添加v-animate指令,比如: ``` <template> <div> <h1 v-animate="'bounce'">例子</h1> </div> </template> ``` 这样就可以实现元素在页面加载时弹跳一次的效果。 总的来说,vue animate.css是一个非常实用的库,可以便捷地实现各种动画效果。具体使用方法可以根据自己的项目需求来灵活运用。 ### 回答3: Vue animate.css是一款能够为Vue应用程序添加动画效果的插件。它通过使用animate.css框架中的动画类名称,实现了Vue动态展示元素的效果。使用Vue animate.css可以省去手写CSS或Javascript动画的烦琐操作,同时可以方便地实现页面元素的动态效果,提升用户体验。 Vue animate.css使用方法如下: 1. 安装Vue animate.css插件,在命令行中运行以下命令: ``` npm install vue-animate-css --save ``` 2. 在Vue组件中引入vue-animate-css的插件: ``` import VueAnimateCss from 'vue-animate-css'; Vue.use(VueAnimateCss); ``` 3. 在组件的模板中添加需要动画效果的元素,并绑定动画类名称: ``` <template> <div> <h1 v-animate-css="'bounceIn'" class="animated">{{ message }}</h1> </div> </template> ``` 4. 在组件的样式表中引入animate.css框架,并为绑定动画类名称的元素添加相应的样式: ``` <style> @import "animate.css"; .animated { animation-duration: 1s; } </style> ``` 5. 在运行应用程序时,就可以看到具有动态效果的元素了。 在以上的使用方法中,v-animate-css即为绑定动画类名称的指令,'bounceIn'为animate.css框架中的一个动画类名称,可以根据需要自由更换。同时,样式表中的animation-duration属性可控制动画持续的时间。 总之,使用Vue animate.css可以在Vue应用程序中方便地实现动态效果,增强用户体验,并且简化了开发人员的操作。但需要注意的是,为了保证页面的性能,应适度使用动画效果,以避免过度设计的问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值