gpt4 book ai didi

jquery - 透明背景在 IE9 中无法正常工作

转载 作者:太空宇宙 更新时间:2023-11-04 04:59:12 25 4
gpt4 key购买 nike

基本上它是一个灯箱演示。代码来自here.我想单击“显示面板”链接,然后弹出一个表单。它在 Firefox 中运行良好,但在 IE9 中出错。

html代码很简单:

<body>
<a id="show-panel" href="#">Show Panel</a>

<div id="lightbox-panel">
<h2>Lightbox Panel</h2>
<p>You can add any valid content here.</p>
<p align="center">
<a id="close-panel" href="#">Close this window</a>
</p>
</div><!-- /lightbox-panel -->

<div id="lightbox"> </div><!-- /lightbox -->
</body>

CSS:

<style type="text/css">

#lightbox {
display:none;
opacity:0.9;
filter:alpha(opacity=90);
position:fixed;
top:0px;
left:0px;
min-width:100%;
min-height:100%;
z-index:1000;
background-color: #FFCC66;
}

#lightbox-panel {
display:none;
position:fixed;
top:180px;
left:50%;
margin-left:-200px;
width:450px;
border:2px solid #CCCCCC;
z-index:1001;
background-color: #999900;
padding-top: 10px;
padding-right: 15px;
padding-bottom: 10px;
padding-left: 15px;
}

.show-panel {
font-family: Arial, Helvetica, sans-serif;
font-size: xx-large;
}
</style>

JQuery 代码:

$("a#show-panel").click(function(){
$("#lightbox, #lightbox-panel").fadeIn(300);
})
$("a#close-panel").click(function(){
$("#lightbox, #lightbox-panel").fadeOut(300);
})

在firefox中的效果: firebox

在IE9中的效果: IE9

不仅是透明背景,灯箱的位置也不对。

感谢您的帮助。

完整代码:

https://skydrive.live.com/?cid=03a8bb9eaeeff1db#cid=03A8BB9EAEEFF1DB&id=3A8BB9EAEEFF1DB!234

最佳答案

问题

正如 Jashwant 所说,这可能是文档类型问题。这正是问题所在。一旦我在 <html> 前面添加了 HTML 5 文档类型,它就被修复了标签。

<!DOCTYPE html>

请记住,IE 不像其他一些浏览器那样智能。因此,您应该为网页使用正确的设置:

<!DOCTYPE html>

<html>
<head>
</head>

<body>
</body>
</html>


它似乎正在处理这个 JsFiddle .

我确实看到你说它在你这边的 JsFiddle 上也能正常工作。那么,您能否将整个 HTML 发布到 pasteTool 上?喜欢pastebin ?这将使修复此问题变得更容易。

有一件事,我想指出的是,您将灯箱垂直居中的方式不均匀。

灯箱的宽度是450px所以对于 margin-left你会想要一半。 450 的一半是 225,所以你的新 margin-left是-225px。

这将使它完美地位于中心。我还喜欢使用 JavaScript 来获取对象的宽度并在其中进行计算。这将需要更长的时间来加载页面,因为它必须做更多的工作,但我认为它工作得很好。

考虑到您认为灯箱似乎无法在该 HTML 页面上工作,这有点偏离主题,但我认为这也可能有用。确保再次检查您的 HTML。可能存在 IE 无法修复而其他浏览器(如 Google Chrome)可以修复的问题。

哦,如果你想将灯箱水平居中,你可以使用相同的方法,你只需将高度减半并使用 margin-top 中的负数形式。

关于jquery - 透明背景在 IE9 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11811962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com