我有一个高于屏幕高度的表格。当用户提交表单时,会弹出一个对话框,并通过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 } });
答案 0 :(得分:1)
试试这个:
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>