我差不多完成了..但是出了点问题:
function doAlert(title,text) {
var alrt='<div onclick="this.parentNode.removeChild(this);" id="alert" style="background-attachment: scroll !important;background-clip: border-box !important;background-color: black !important;background-image: none !important;background-origin: padding-box !important;background: black !important;border-bottom-left-radius: 20px 20px !important;border-bottom-right-radius: 20px 20px !important;border-top-left-radius: 20px 20px !important;border-top-right-radius: 20px 20px !important;color: white !important;display: block !important;height: 480 !important;left: 50% !important;margin-bottom: 0 !important;margin-left: -360px !important;margin-right: 0 !important;margin-top: -260 !important;opacity: 0.8 !important;overflow-x: auto !important;overflow-y: auto !important;overflow: auto !important;padding-bottom: 20px !important;padding-left: 20px !important;padding-right: 20px !important;padding-top: 20px !important;position: absolute !important;text-align: center !important;top: 50% !important;width: 640 !important;z-index: 99999999 !important;font-size:3em !important;">';
alrt+=title;
alrt+='<div id=alertbody style="text-align: justify;font-size:.5em;">';
alrt+=text;
alrt+='</div>';
alrt+='</div>';
var zalert=document.createElement("div");
zalert.innerHTML=alrt;
document.body.insertBefore(zalert.firstChild,document.body.firstElementChild)
}
此功能在普通页面上运行良好
它不适用于重型页面。
我试着在我的风格中添加“!important”,但它没有帮助
如果您在以下页面中尝试此代码:http://www.zibri.org(例如)
请求者的大小不正确,也不是正确的位置。
有什么问题?
答案 0 :(得分:0)
问题是某些宽度和高度都缺少“px”.. 这里你去:
function doAlert(title,text) {
var alrt='<div onclick="this.parentNode.removeChild(this);" id="alert" style="background-attachment: scroll !important;background-clip: border-box !important;background-color: black !important;background-image: none !important;background-origin: padding-box !important;background: black !important;border-bottom-left-radius: 20px 20px !important;border-bottom-right-radius: 20px 20px !important;border-top-left-radius: 20px 20px !important;border-top-right-radius: 20px 20px !important;color: white !important;display: block !important;height: 480px !important;left: 50% !important;margin-bottom: 0 !important;margin-left: -360px !important;margin-right: 0 !important;margin-top: -260px !important;opacity: 0.8 !important;overflow-x: auto !important;overflow-y: auto !important;overflow: auto !important;padding-bottom: 20px !important;padding-left: 20px !important;padding-right: 20px !important;padding-top: 20px !important;position: fixed !important;text-align: center !important;top: 50% !important;width: 640px !important;z-index: 99999999 !important;font-size:3em !important;">';
alrt+=title;
alrt+='<div id=alertbody style="text-align: justify;font-size:.5em;">';
alrt+=text;
alrt+='</div>';
alrt+='</div>';
var zalert=document.createElement("div");
zalert.innerHTML=alrt;
document.body.insertBefore(zalert.firstChild,document.body.firstElementChild)
}
随意改进它..但是在这里发布结果! :)