我正在使用 DataTables jQuery 插件来显示网格。我有一个模式弹出窗口,它改变了整个表单的背景颜色,并且意外地改变了前面提到的表格页眉和页脚背景颜色的背景颜色。这是用于初始化弹出窗口的代码:
var modalBackground = $("#modalBackground");
var Notifications_ArchiveHolder = $("#Notifications_ArchiveHolder");
var Notifications_ShowArchivePopupHolder = $("#Notifications_ShowArchivePopupHolder");
var ArchiveURL = "@Url.Action("Archive")";
var ShowArchiveUrl = "@Url.Action("ShowArchive")";
function ShowArchivePopup() {
$.get(ArchiveURL, function (content) {
if (Notifications_ArchiveHolder.html().length <= 10) {
Notifications_ArchiveHolder.html(content);
InitArchivePopup();
}
})
}
function InitArchivePopup() {
modalBackground.show();
//set up positon
var h = $(window).height();
var w = $(window).width();
var hh = Notifications_ArchiveHolder.height();
var hw = Notifications_ArchiveHolder.width();
var posx = (h / 2) - 100;
var posy = (w / 2) - 200;
Notifications_ArchiveHolder.css("position", "fixed");
Notifications_ArchiveHolder.css("top", posx);
Notifications_ArchiveHolder.css("left", posy);
Notifications_ArchiveHolder.show();
$("body").css("overflow", "hidden");
}
弹出窗口托管在以下 div 中:
<div id="Notifications_ArchiveHolder" style="background-color: white; display: none; z-index: 9999;"></div>
这是 div 的 css 类使整个背景变为灰色,并且还更改了我的表格的页眉和页脚背景颜色:
<div id="modalBackground" class="graphicScreen" style="display: none; position: fixed; top: 0px; left: 0px;"></div>
.graphicScreen
{
position: fixed;
width: 100%;
height: 100%;
margin: 0;
padding: 50px;
background-color: #878786;
z-index: 9990;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity=30);
-moz-opacity: 0.3;
-khtml-opacity: 0.3;
opacity: 0.3;
}
知道为什么会发生这种情况以及如何预防吗?提前致谢。