I use the jQuery dialog with position: fixed on my website. On PC this dialog has the center position by default.
On mobile device, it sets the position to the top left. I tried different methods but it failed to position this dialog center on mobile.
Code:
CSS:
.ui-dialog {
position: fixed;
top: 0;
left: 0;
padding: .2em;
outline: 0;
}
JS:
function isMobileDevice() {
var mobileRegEx = new RegExp("Android|webOS|iPhone|iPad|iPod|BlackBerry", "i");
return mobileRegEx.test(navigator.userAgent);
}
$("#myDialog").dialog({
title: "Info",
closeText: "Close",
width: 440,
minWidth: 440,
height: 250,
minHeight: 250,
modal: true,
resizable: false,
open: function() {
if (isMobileDevice()) {
$(this).dialog("option", "position", { my: "center", at: "center", of: window });
}
}
});
Any ideas how to set it to the center on mobile device? Thank you for your help.
