css3自定义动画和animate.css 动画

本文介绍如何通过Animate.css库为网页元素添加动画效果。首先需引入animatecss文件,然后给目标元素添加动画样式名。文章提供了一个使用jQuery动态添加动画样式的示例,并展示了如何在鼠标悬停时触发动画。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、首先引入animate css文件

<link rel="stylesheet" href="animate.min.css">

2、给指定的元素加上指定的动画样式名

<div class="animated bounceOutLeft"></div>
这里包括两个class名,第一个是基本的,必须添加的样式名,任何想实现的元素都得添加这个。第二个是指定的动画样式名

3、如果说想给某个元素动态添加动画样式,可以通过jquery来实现

$('#yourElement').addClass('animated tada');

4、一个简单的例子

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>css动画</title>
		<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" rel="stylesheet">
		<style type="text/css">
			.cc {
				-moz-transition: all 0.5s ease-in-out;
				/* Firefox 4 */
				-webkit-transition: all 0.5s ease-in-out;
				/* Safari 和 Chrome */
				-o-transition: all 0.5s ease-in-out;
				/* Opera */
				transition: all 0.5s ease-in-out;
			}
			
			.bbb {
				-webkit-transform: scale(1.1);
				transform: scale(1.1);
			}
		</style>
	</head>

	<body class="gray-bg">
		<div id="111" style="background-color: red;width: 120px;height: 120px;margin: auto;margin-top: 100px;" class="cc"></div>
		<div id="222" style="background-color: blue;width: 120px;height: 120px;margin: auto;margin-top: 100px;" ></div>
	</body>
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js"></script>
	<script type="text/javascript">
		$("#111").mouseover(function() {
			$('#111').addClass('bbb');
		}).mouseout(function() {
			$('#111').removeClass('bbb');
		});
		
		
		$("#222").mouseover(function() {
			$('#222').addClass('animated tada');
		}).mouseout(function() {
			$('#222').removeClass('animated tada');
		});
	</script>

</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

左本Web3D

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值