Z-index属性和弹框打开和关闭

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<style type="text/css">

	#abc{
		height: 100%;
		width: 100%;
		background-color: rgba(0, 0, 0, 0.4);
		position: fixed;
	    top: 0; 
		left: 0;
		z-index: 99;
		display: none;
	}
	#first{
		height: 400px;
		width: 400px;
		background: #fff;
		margin: auto;
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 100;
	}
	#first #close{
		float: right;
		font-weight: bold;
		cursor: pointer;
		margin-right: 20px;
		
	}
	#first .second{
		border-top: 1 solid gray;
		text-align: center;
	}
	
</style>

<script type="text/javascript">
	$(document).ready(function(){
		$(".tanchu").click(function(){
			$("#abc").toggle("fast").css({
			'top':(heigth)+'px',
			'left':(width)+'px'
				});
		});
		 $("#close").click(function(){
				$("#abc").hide();
				
				}); 
	});
	//设置弹出框 和滚动条一起滚动
	$(window).scroll( function() {
	var height=$(this).scrollTop(); //获得滚动条距窗口顶部的高度
	$("#abc").css('margin-top',(height));
	});
	
</script>
</head>
<body>
		<input type="button" value="弹出" class="tanchu">
		<div id="abc">		
				<div id="first">					
						<p class="title">请选择<span id="close" >X</span></p>
						
						
					<div class="second">
						<option>山东</option>
						<option>广东</option>
						<option>湖南</option>
					</div>					
				</div>
		</div>	
		<div class="bcd">
			<span><a href="">我要收藏</a></span>
		</div>	
</body>
</html>



Z-index属性:值越大覆盖值越小的

打开:点弹出按钮,触发事件,对前端样式进行控制

关闭:将X 变为cursor: pointer;  来个事件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值