0

I have a problem centering div in Firefox, it seems to work fine in all webkit browsers, so I dont really know what I'm doing wrong:

My 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%;
}

My HTML:

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

Is this a bug within the Gecko engine or am I doing something wrong.

David Greiner
  • 318
  • 4
  • 6

3 Answers3

0

Horizontal align works fine for me, vertical seems to be the problem, try this, maybe.

#loginBackground
{
top:0;
margin-top: 5%;
}
mamadrood
  • 739
  • 5
  • 12
0

EDIT new fiddle 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>
user1289347
  • 2,397
  • 1
  • 13
  • 16
0

use #page{ width:980px; margin:10px auto; } #LoginBackground{ margin:50px auto;
width:500px; }

sohaan
  • 637
  • 1
  • 10
  • 18