Z-index属性和弹框打开和关闭
2016-12-30 15:46
225 查看
<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; 来个事件
相关文章推荐
- 由于一个或多个其它网络页属性已经打开,这个属性页上的部分控件被禁用,要想使用这些软件,请先关闭所有属性页,然后将这个属性页重新打开
- 由于一个或多个其他网络页属性已经打开,这个属性页上的部分控件被禁用。想要使用这些控件,请先关闭所有属性页,然后将这个属性页重新打开
- (八)linux下编程实现ls功能的打开、访问 、关闭目录以及提取属性。
- html(object)控制ie的打印、刷新、另存、关闭、打开、页面设置、属性、打印预览
- Android属性设置android:noHistory="true",打开下一个Activity关闭本Activity
- 打开或关闭IGeometry的Z属性
- android webview css z-index属性无效
- 如何打开或关闭windows的测试模式
- Oracle 数据库的打开与关闭
- 如何关闭打开了多个activity的activity
- 安卓输入法界面的关闭/打开
- 打开窗口、关闭窗口
- Win7 打开或关闭Windows功能 窗口空白 解决方案(转载)
- easyui tabs中打开新的tabs关闭当前tabs
- CentOS7使用firewalld打开关闭防火墙与端口
- linux下关闭打开指定端口的程序的脚本
- cmd打开系统属性