4var messageBoxDiv = '<div id="alertBox" class="alert alertbox"><div class="alertHeader errorAlert"></div><div id="alertContent" class="alertContent"></div><div id="alertBottom" class="alertBottom"></div>'; 5var button = '<input id="alertOkButton" class="alertOkButton" type="button" rel=""/>';
6 alertSpace.open = function (type, message) {
7 $("body").append(backgroundDiv);
8 $("body").append(messageBoxDiv);
9 $("#alertBackground").show();
10 $("#alertBox").show();
11if(type == 'error'){
12 $("#alertBottom").addClass("errorBottom");
13 $("#alertBottom").append(button);
14 $("#alertOkButton").val("确定");
15 $("#alertOkButton").click(close);
16 $("#alertContent").html(message);
17 }
18 };
19function close() {
20 $("#alertBackground").remove();
21 $("#alertBox").remove();
22 };
23 })(this.document);
css相关代码
1.alertbox {
2 height: 232px;
3 width: 500px;
4/*box-shadow: rgb(136, 136, 136) 10px 10px 10px 5px;*/
5 border-radius: 20px;
6 position: absolute;
7 top: 50%;
8 left: 50%;
9 margin-left: -250px;
10 margin-top: -116px;
11 z-index: 1011;
12 background-color: #fff;
13 padding:0px;
14 border:0px;
15 }
16
17.alert .alertHeader {
18 height: 100px;
19 margin-top: -50px;
20 border-radius: 50px;
21 }
22
23.alert .errorAlert {
24 background: url(images/errorAlertTitle.png) no-repeat center center;
25 }
26
27.alert .alertContent {
28 height: 124px;
29 font-family: Microsoft YaHei;
30 font-size: 24px;
31 padding-top: 48px;
32 text-align: center;
33 }
34
35.alert .alertBottom {
36 height: 60px;
37 }
jquery框架定义38
39.alert .errorBottom {
40 background: -webkit-gradient(linear, 0% 100%, 100% 0%, from(#e2bc00),to(#e39901));
41 border-radius: 0 0 20px 20px;
42 background: -ms-linear-gradient(left, #e2bc00,#e39901);
43 border:0px;
44 }
45
46.alert .alertOkButton {
47 background-color: transparent;
48 width: 100%;
49 border: 0px;
50 font-family: Microsoft YaHei;
51 letter-spacing: 12px;
52 font-size: 24px;
53 color: #fff;
54 height: 100%;
55 }
56
57.alertBackground {
58 width: 100%;
59 height: 100%;
60 opacity: 0.4;
61 filter: alpha(opacity=40);
62 background: #000;
63 position: absolute;
64 top: 0;
65 left: 0;
66 z-index: 1010;
67 }
调⽤代码
添加js和css的引⽤,调⽤alertSpace.open()实现效果
当前只实现了Error的逻辑
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论