When positioning a modal vertically, how can I ensure consistent alignment across different browsers?
method.center = function () {
var top, left;
top = Math.max($(window).height() - $modal.outerHeight(), 0) / 2;
left = Math.max($(window).width() - $modal.outerWidth(), 0) / 2;
$modal.css({
top:top + $(window).scrollTop(),
left:left + $(window).scrollLeft()
});
};
Despite centering horizontally correctly, Firefox consistently adds 157px to the top calculation. Is there a more reliable method to calculate window height, subtract modal height, and divide by 2 for consistent vertical alignment?