‘left’ : (getWindowInnerWidth() – dialog.width()) / 2 + ‘px’
});
// 窗口DIV圆角
dialog.find(‘.modal-container’).css(‘border-radius’,’6px’);
// 模态窗口关闭按钮事件
dialog.find(‘.btn-close’).click(function(){
closeModal();
});
// 显示遮罩层
showOverlay();
// 显示遮罩层
dialog.show();
}
/**
* 模拟关闭模态窗口DIV
*/
function closeModal() {
$(‘.overlay’).hide();
$(‘#modalDiv’).hide();
$(‘#modalDiv’).html(”);
}
body.html
XML/HTML Code复制内容到剪贴板
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Commpatible" content="IE=edge">
<title>body 页面</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html, body {
width: 100%;
height: 100%;
}
.outer {
width: 200px;
height: 120px;
position: relative;
top: 50%;
left: 50%;
}
.inner {
width: 200px;
height: 120px;
position: relative;









