1、CSS样式
<style type="text/css">
body { font:11px/1.6em Microsoft Yahei; background:#fff; line-height:1.6em; outline:none;}
html,body,div,ul,ol,li,p,iframe,h1,h2,dl,dt,dd { margin:; padding:;}
.mask { width:100%; height:100%; background:rgba(0,0,0,0.6); display:none; position:fixed; _position:absolute; top:; left:; z-index:;}
.dialog { min-height:120px; background:#fff; display:none; position:fixed; top:8%; left:50%; z-index:; box-shadow:3px 3px 5px #000;}
.dialog a.close { display:block; width:22px; height:22px; background:url(images/close.png) center no-repeat #fff; text-indent:-9999em;}
.dialog a.close { position:absolute; top:; right:; z-index:;}
.dialog.loading { background:url(images/loading.gif) center no-repeat #fff;}
.dialog-content { padding:22px 10px 10px 10px;}
</style>
2、HTML代码
<div class="mask"></div>
<div class="dialog">
<a href="javascript:void(0)" class="close" title="关闭">关闭</a>
<div class="dialog-content"></div>
</div>
3、Javascript
<script type="text/javascript">
$(function () {
$('.dialog').find('a.close').bind("click", function () {
Dialog.close();
});
}); var Dialog = {
mask: $('.mask'),
dialog: $('.dialog'),
content: $('.dialog-content'),
open: function (width, height, appendHtml) {
Dialog.mask.fadeIn(500);
Dialog.dialog.css({ width: width, height: (height + 22), marginLeft: -(parseInt(width) / 2) }).addClass('loading').fadeIn(500, function () {
Dialog.dialog.removeClass('loading');
Dialog.content.append(appendHtml);
});
},
close: function () {
Dialog.mask.fadeOut(500);
Dialog.dialog.fadeOut(500, function () {
Dialog.content.empty();
});
}
}
</script>
4、预览效果