JQuery实现笼罩层
来源:互联网 发布:拼图游戏源码 编辑:程序博客网 时间:2024/06/12 01:28
引用Jquery1.4.2及以上版本,测试中发现引用css路径之间要加(.)请注意哦!
页面:d.html
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jquery实现遮罩层</title>
<!-- <link href="/css/d.css" rel="stylesheet" type="text/css" /> -->
<link href="./css/d.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.4.2.js"> </script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"> </script>
</head>
<body>
<p class="showbtn"><a href="javascript:void(0);">显示遮罩层</a></p>
<div id="bg"></div>
<div class="box" style="display:none">
<h2>jQuery 学习交流<a href="#" class="close">关闭</a></h2>
<div class="list">
<table>
<tr>
<td>牛B</td>
<td><input type="text" id="test"></td>
</tr>
<tr>
<td>2B</td>
<td><input type="text" id="test"></td>
</tr>
<tr>
<td>SX</td>
<td><input type="text" id="test"></td>
</tr>
<tr>
<td>BZ</td>
<td><input type="text" id="test"></td>
</tr>
</table>
</div>
</div>
<script type="text/javascript">
$(function () {
$(".showbtn").click(function () {
alert("到我这了");
alert($(document).height());
$("#bg").css({
display: "block", height: $(document).height()
});
var $box = $('.box');
$box.css({
//设置弹出层距离左边的位置
left: ($("body").width() - $box.width()) / 2 - 20 + "px",
//设置弹出层距离上面的位置
top: ($(window).height() - $box.height()) / 2 + $(window).scrollTop() + "px",
display: "block"
});
});
//点击关闭按钮的时候,遮罩层关闭
$(".close").click(function () {
$("#bg,.box").css("display", "none");
});
});
</script>
</body>
</html>
CSS:d.css
/* box */
.box{position:absolute;width:600px;left:50%;height:auto;z-index:100;background-color:#fff;border:1px #ddd solid;padding:1px;}
.box h2{height:25px;font-size:14px;background-color:#aaa;position:relative;padding-left:10px;line-height:25px;color:#fff;}
.box h2 a{position:absolute;right:5px;font-size:12px;color:#fff;}
.box .list{padding:10px;}
.box .list li{height:24px;line-height:24px;}
.box .list li span{margin:0 5px 0 0;font-family:"宋体";font-size:12px;font-weight:400;color:#ddd;}
.showbtn {font:bold 24px '微软雅黑';}
#bg{background-color:#666;position:absolute;z-index:99;left:0;top:0;display:none;width:100%;height:100%;opacity:0.5;filter: alpha(opacity=50);-moz-opacity: 0.5;}
- JQuery实现笼罩层
- css 弹出窗口之后的笼罩层
- jquery实现弹出层
- JQUERY实现拖动层
- JQuery实现悬浮层
- jQuery实现浮动层
- jquery 实现弹出层效果
- jquery 实现弹出层插件
- jQuery 实现拖动浮动层
- 页面加载时让其显示笼罩层与加载等待图片
- CSS+JQUERY实现遮盖层效果
- 使用jquery实现弹出层效果
- jQuery实现很炫很酷的弹出层效果
- jQuery实现很炫很酷的弹出层效果
- Jquery仿京东分类导航层简单实现
- jQuery实现小功能之弹出层
- jQuery实现网页右下角悬浮层提示
- jQuery和css实现半透明遮盖层
- Sublime Text 3 Windows下简单安装配置
- 【BZOJ 2219】【超详细题解】数论之神
- Subsets II
- 提升Web性能的8个技巧总结
- 方法的重载(overload)和覆盖(override)
- JQuery实现笼罩层
- 如何使用Docker进行Java入门级开发
- js中indexof
- seajs+easyui实战
- Android性能优化典范
- Eclipse调试技巧
- 淘宝内部分享:怎么跳出MySQL的10个大坑
- 堆排序
- Android TextView文本文字修改实例