---
title: "遮罩层 非原创"
author: "ktz666"
date: "2010-10-15T22:50:07Z"
tags: []
categories: ["企业架构"]
slug: "untitled"
draft: false
lastmod: "2010-10-15T22:50:07Z"
id: 786118
url: "https://ktz666.iteye.com/blog/786118"
---

01. &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
02. &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
03. &lt;head&gt;
04. &lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312" /&gt;
05. &lt;title&gt;弹出提示&lt;/title&gt;
06. &lt;style&gt;
07. * {margin:0;padding:0;font-size:12px;}
08. html,body {height:100%;width:100%;}
09. #content {background:#FFFFFF;padding:30px;height:100%;}
10. #content a {font-size:30px;color:#369;font-weight:700;}
11. #alert {border:1px solid #369;width:300px;height:150px;background:#e2ecf5;z-index:1000;position:absolute;display:none;}
12. #alert h4 {height:20px;background:#369;color:#fff;padding:5px 0 0 5px;}
13. #alert h4 span {float:left;}
14. #alert h4 span#close {margin-left:210px;font-weight:500;cursor:pointer;}
15. #alert p {padding:12px 0 0 30px;}
16. #alert p input {width:120px;margin-left:20px;}
17. #alert p input.myinp {border:1px solid #ccc;height:16px;}
18. #alert p input.sub {width:60px;margin-left:30px;}
19. &lt;/style&gt;
20. &lt;/head&gt;
21. &lt;body&gt;
22. &lt;div id="content"&gt;
23. &lt;a href="#"&gt;注册&lt;/a&gt;
24. &lt;/div&gt;
25. &lt;div id="alert"&gt;
26. &lt;h4&gt;&lt;span&gt;现在注册&lt;/span&gt;&lt;span id="close"&gt;关闭&lt;/span&gt;&lt;/h4&gt;
27. &lt;p&gt;&lt;label&gt; 用户名&lt;/label&gt;&lt;input type="text" **class**="myinp" onmouseover="this.style.border='1px solid #f60'" onfoucs="this.style.border='1px solid #f60'" onblur="this.style.border='1px solid #ccc'" /&gt;&lt;/p&gt;
28. &lt;p&gt;&lt;label&gt; 密　码&lt;/label&gt;&lt;input type="password" **class**="myinp" onmouseover="this.style.border='1px solid #f60'" onfoucs="this.style.border='1px solid #f60'" onblur="this.style.border='1px solid #ccc'" /&gt;&lt;/p&gt;
29. &lt;p&gt;&lt;input type="submit" value="注册" **class**="sub" /&gt;&lt;input type="reset" value="重置" **class**="sub" /&gt;&lt;/p&gt;
30. &lt;/div&gt;
31. &lt;script type="text/javascript"&gt;
32. **var** myAlert = document.getElementById("alert");
33. **var** reg = document.getElementById("content").getElementsByTagName("a")\[0];
34. **var** mClose = document.getElementById("close");
35. reg.onclick = **function**()
36. {
37. myAlert.style.display = "block";
38. myAlert.style.position = "absolute";
39. myAlert.style.top = "50%";
40. myAlert.style.left = "50%";
41. myAlert.style.marginTop = "-75px";
42. myAlert.style.marginLeft = "-150px";
43. mybg = document.createElement("div");
44. mybg.setAttribute("id","mybg");
45. mybg.style.background = "#000";
46. mybg.style.width = "100%";
47. mybg.style.height = "100%";
48. mybg.style.position = "absolute";
49. mybg.style.top = "0";
50. mybg.style.left = "0";
51. mybg.style.zIndex = "500";
52. mybg.style.opacity = "0.3";
53. mybg.style.filter = "Alpha(opacity=30)";
54. document.body.appendChild(mybg);
55. document.body.style.overflow = "hidden";
56. }
57. mClose.onclick = **function**()
58. {
59. myAlert.style.display = "none";
60. mybg.style.display = "none";
61. }
62. &lt;/script&gt;
63. &lt;/body&gt;
64. &lt;/html&gt;