如何使用纯js实现一个带有灰色半透明背景的弹出框

原文 如何使用纯js实现一个带有灰色半透明背景的弹出框

// 加入透明背景 
var body = document.body;
var backgroundDiv = document.createElement("div");
backgroundDiv.style.cssText = "left:0;top:0;
position:fixed;
background:#ddd;opacity:0.8;100%;height:100%";
body.appendChild(backgroundDiv);
// 加入居中弹出框
var newDiv = document.createElement("div");
newDiv.style.cssText = "position:absolute;margin:auto;
left:0;right:0;top:0;
bottom:0;400px;
height:200px;background:white;";
backgroundDiv.appendChild(newDiv); // 丰富弹出框内容 ......
原文地址:https://www.cnblogs.com/xiaoshen666/p/10951323.html