I have a jQuery dialog box that is meant to position in the middle of the screen. However, it seems slightly off-center vertically.
Here is the code:
$('#add_box').dialog({
autoOpen: true,
width: 300,
modal: true,
resizable: false,
bgiframe:true
});
Any ideas why this won't center?
to position the dialog in the center of the screen :
Add this to your dialog declaration
Example :
To fix this issue I made sure my body height was set to 100%.
This also maintains the center position while the user scrolls.
I had the same problem, which was fixed when I entered a height for the dialog:
For me jquery.dimensions.js was the Culprit
This solution does work but only because of the newer jQuery versions ignoring this completely and falling back to the default, which is exactly this. So you can just remove position: 'center' from your options if you just want the pop up to be centered.