I have attempted to create an image preview effect using JavaScript that opens any image clicked in full screen mode. The image itself uses the following code to center itself based upon its size.
position: fixed;
top: 50%;
left: 50%;
Simplified Javascript | See All | Result
el.style.margin = "-" + el.height / 2 + "px -" + el.width / 2 + "px";
This code functions properly in Firefox, but in Webkit browsers the image is pushed into the top-left corner and has obscure negative margins. Why does this Javascript not work in Webkit browsers? How should I go about fixing this code?