jQuery实现弹窗动画(自下而上,自上而下,渐隐渐现)

目录

弹窗自下而上,自上而下(slideDown(),slideUp()),可设置回调函数。slideToggle()能实现slideDown(),slideUp()这两种功能

弹窗渐隐渐现(fadeIn(),fadeOut()),可设置回调。fadeToggle()能实现fadeIn(),fadeOut()这两种功能

fadeTo(时间,透明度):可指定透明度


弹窗自下而上,自上而下(slideDown(),slideUp()),可设置回调函数。slideToggle()能实现slideDown(),slideUp()这两种功能

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>jQuery实现广告弹窗</title>
		<script type="text/javascript" src="js/jquery-3.3.1.js" ></script>
		<style type="text/css">
			#ad{
				width: 300px;
				height: 300px;
				background-color: yellowgreen;
				bottom: 0;
				right: 0;
				position: fixed;
				display: none;
			}
		</style>
		<script type="text/javascript">
			setTimeout(function(){
			   $("#ad").slideDown(2000);
			},1000)
			
			$(function(){
				$("#closeBtn").click(function(){
					$("#ad").slideUp("fast");
				})
			})
		</script>
	</head>
	<body>
		<div id="ad">
			<button id="closeBtn">关闭</button>
		</div>
	</body>
</html>

弹窗渐隐渐现(fadeIn(),fadeOut()),可设置回调。fadeToggle()能实现fadeIn(),fadeOut()这两种功能

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>jQuery实现广告弹窗</title>
		<script type="text/javascript" src="js/jquery-3.3.1.js" ></script>
		<style type="text/css">
			#ad{
				width: 300px;
				height: 300px;
				background-color: yellowgreen;
				bottom: 0;
				right: 0;
				position: fixed;
				display: none;
			}
		</style>
		<script type="text/javascript">
			setTimeout(function(){
			   $("#ad").fadeIn(2000);
			},1000)
			
			$(function(){
				$("#closeBtn").click(function(){
					$("#ad").fadeOut("slow");
				})
			})
		</script>
	</head>
	<body>
		<div id="ad">
			<button id="closeBtn">关闭</button>
		</div>
	</body>
</html>

fadeTo(时间,透明度):可指定透明度

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>jQuery实现广告弹窗</title>
		<script type="text/javascript" src="js/jquery-3.3.1.js" ></script>
		<style type="text/css">
			#ad{
				width: 300px;
				height: 300px;
				background-color: yellowgreen;
				bottom: 0;
				right: 0;
				position: fixed;
				display: none;
			}
		</style>
		<script type="text/javascript">
			setTimeout(function(){
			   $("#ad").fadeTo (1000,0.5);//0 完全透明;1 完全不透明
			},1000)
			
			$(function(){
				$("#closeBtn").click(function(){
					$("#ad").fadeToggle("slow");
				})
			})
		</script>
	</head>
	<body>
		<div id="ad">
			<button id="closeBtn">关闭</button>
		</div>
	</body>
</html>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值