You need to check the height and width of the element you’re centering on and set the top and left accordingly.
$('.labelEdit').click( function() {
var x = $("#editDialog").width() / 2 - $("#editItemDialog").outerWidth() / 2;
var y = $("#editDialog").height() / 2 - $("#editItemDialog").outerHeight() / 2;
$("#editItemDialog").css({"top": y, "left": x});
$('#editItemDialog').show('slow');
});
Basically, we’re setting the top corner at the midpoint of the target div minus half the height of the dialog and the left at the midpoint minus half the width of the dialog.
solved trying to get an absolute positioned div to center within another relative positioned div