colmtuite
colmtuite

Reputation: 4491

Firefox weird percentage height absolutely positioned div

I have a pure CSS modal dialog set up like this

div {
  position:fixed;
  top:50%;
  left:50%;
  margin:-26% 0 0 -26%;
  width:46%;
  height:46%;
  padding:3%;
}

This div displays centered in webkit browsers. In FF however, it's almost touching the top of the screen.

Upvotes: 0

Views: 104

Answers (1)

Michael Peterson
Michael Peterson

Reputation: 1123

Rather than using margins, you could do:

top: 25%;
left: 25%;

http://jsfiddle.net/wwRUT/2/

I don't think I'd combine margins and fixed positioning.

Upvotes: 3

Related Questions