我有一个比屏幕高度高的东西。 当用户提交表单时,会弹出一个对话框,并通过 AJAX 询问并确认其密码。 我的问题是对话框总是出现在屏幕的最底部,即使使用下面的jQuery代码也是如此,我相信这是正确的。
<div id="passConfirmBox">
<p class="confirmError">Invalid password, try again</p>
<p><input type="password" name="passwordField" id="passwordField" value=""></p>
<button type="button" id="passConfirmButton">Confirm Password</button>
</div>
var passConfirm = $("#passConfirmBox").dialog( { title: "Confirm Your Password",
autoOpen: false, position: { my: "center", at: "center", of : window } });
试试这个:
var myPos = { my: "center top", at: "center top+150", of: window };
您的完整脚本:
<script>
$(function() {
var myPos = { my: "center top", at: "center top+150", of: window };
var passConfirm = $("#passConfirmBox").dialog( { title: "Confirm Your Password",
autoOpen: true, position: myPos});// autoOpen is set to true to test you can change it to your use.
});
</script>
</head>
<body>
<div id="passConfirmBox">
<p class="confirmError">Invalid password, try again</p>
<p><input type="password" name="passwordField" id="passwordField" value=""></p>
<button type="button" id="passConfirmButton">Confirm Password</button>
</div>