中心div垂直,与webkit工作正常,但Firefox中的错误

时间:2012-04-19 17:53:27

标签: css webkit gecko

我在Firefox中存在div问题,它似乎在所有webkit浏览器中运行良好,所以我真的不知道我做错了什么:

我的CSS:

html {
width: 100%;
height: 100%;
}

body {
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
height: 100%;
width: 100%;
}

#Page {
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
}

#LoginBackground {
position: absolute;
margin-top: -45%;
margin-left: -35%;
left: 50%;
top: 50%;
width: 70%;
height: 90%;
}

我的HTML:

<body>
<div id="Page">
<div id="LoginBackground">
</div>
</div>
</body>

这是Gecko引擎中的错误还是我做错了什么。

3 个答案:

答案 0 :(得分:0)

水平对齐对我来说很好,垂直似乎是问题,尝试这个,也许。

#loginBackground
{
top:0;
margin-top: 5%;
}

答案 1 :(得分:0)

EDIT 新小提琴http://jsfiddle.net/FsjNu/2/

html {
width: 100%;
height: 100%;
}

body {
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
height: 100%;
width: 100%;
}

#Page {
position: relative;
width: 100%;
    height:100%;
}

#LoginBackground {
border: 1px solid red;
height: 90%;
left: 50%;
margin-left: -35%;
position: absolute;
top: 5%;
width: 70%;

}

<body>
<div id="Page">
<div id="LoginBackground">
</div>
</div>
</body>

答案 2 :(得分:0)

使用     #页{     宽度:980px;     保证金:10px auto;     }     #LoginBackground {     保证金:50px auto;
    宽度:500像素;     }