2012-01-14 50 views
-2

下面的代码在Firefox中可以工作,但不在IE中。IE浏览器:中心和覆盖屏幕上的div

我需要正确屏幕居中 - 右现的股利是一边倒太多底部

我也需要做出这个div(ID =“加载”),以封面上的格整个窗口 - 并采取所有的点击,以防止点击其他地方。

它需要与IE兼容。

HTML

<html> 
<head> 
<title>Overlay</title> 
    <link href="loading.css" rel="stylesheet" type="text/css" /> 

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
    <script type="text/javascript" src="loading.js"></script> 
</head> 
<body> 
This paragraph is for testing 
<br/> 
Hello world! 
<br/> 
How are you? 
<br/> 
Be happy! 
<br/> 
<input id="cmd" type="button" value="Test" /> 
</body> 
</html> 

CSS

#loading { 
    background-color: black; 
    background-color: rgba(1, 1, 1, 0.7); 
    bottom: 0; 
    left: 0; 
    position: fixed; 
    right: 0; 
    top: 0; 
} 

#loading_box { 
    width: 150px; 
    height: 35px; 
    border: 5px solid #FFFFFF; 
    padding: 5px; 

    text-align: center; 
    margin-top: 50%; 
    margin-left: 50%; 
    position: relative; 
    top: -15.5px 
} 

#loading_img { 
    width: 31px; 
    height: 31px; 
} 

#loading_txt { 
    color: #49a0dc; 
    font-weight: bold; 
    margin-left: 0.5em; 
    font-family: "Arial Black", Gadget, sans-serif; 
} 

示例文件 http://punkbunny.com/tmp/overlay/overlay.html

+2

这不是_greatest_的问题,但为什么downvotes?来吧,人们!发表你的意见,以便他可以解决你不喜欢的任何问题。 – 2012-01-14 00:39:15

+2

对不起,这太本地化了。你不能把你的整个代码转储到这里,并期望我们为你调试它。另外,你是否尝试在网上搜索对话/模式/覆盖jQuery插件而不是从头开始自己编写? – 2012-01-14 00:40:53

+1

@ frederic-hamidi我会说:为什么我不能使用我自己的代码?这个地方是帮助程序员,专家与否。不是一个可以改变人们做事情的网站......我是美国人,喜欢第五修正案,它为我们提供言论自由而不是压制! – Omar 2012-01-14 00:54:25

回答

2

用途:

#loading_box { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    margin-top: -17px; 
    margin-left: -75px; 
} 

instea d的position: relative;margin s在#loading_box元素上。使用这些将很难得到你想要的效果。

1

您的文档类型不正确,导致IE进入怪癖模式。改为使用这一个,看看我们的立场:<!DOCTYPE html>