简体   繁体   English

jQuery UI对话框的位置

[英]jQuery UI Dialog Box Position

I have a form that is taller than the screen height. 我的表格比屏幕高度高。 When the user submits the form, a dialog box pops up and asks and confirms their password via AJAX. 用户提交表单后,会弹出一个对话框,并通过AJAX询问并确认密码。 My problem is that the dialog box always appears at the very bottom of the screen, even when using the jQuery code below, which I believe is correct. 我的问题是,即使使用下面的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 } });

try this: 尝试这个:

var myPos = { my: "center top", at: "center top+150", of: window };

your complete script: 您的完整脚本:

 <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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM