前端中animation控制动画定位到动画结束,并使用js控制3s消失

本文介绍了如何在前端中让动画在结束时停留在结束位置,并使用JavaScript控制元素在3秒后消失。通过设置CSS动画及JS操作DOM实现这一功能,详细讲解了两种不同的JS执行方式。
摘要由CSDN通过智能技术生成
  1. 代码
<!DOCTYPE html>
<html>
<head>
	<title>home</title>
	<meta charset="utf-8">
	<style type="text/css">
		.fix_tip{
			width: 500px;
			height: 48px;
			left: 50%;
			margin-left: -250px;
			font-size: 24px;
			line-height: 48px;
			position: fixed;
			background: red;
			color: white;
			text-align: center;
			z-index: 1;
			border: 1px solid red;
			animation:myfirst 3s forwards;
			-moz-animation:myfirst 3s forwards; /* Firefox */
			-webkit-animation:myfirst 3s forwards; /* Safari and Chrome */
			-o-animation:myfirst 3s forwards; /* Opera */
		}
		@keyframes myfirst{
			from{top:0px}
			to{top:100px}
		}
		/* Firefox */
		@-moz-keyframes myfirst {
			from{top:0px}
			to{top:100px}
		}
		/* Safari and Chrome */
		@-webkit-keyframes myfirst {
			from{top:0px}
			to{top:100px}
		}
		 /* Opera */
		@-o-keyframes myfirst{
			from{top:0px}
			to{top:100px}
		}
	</style>
&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值