簡體   English   中英

jQuery UI對話框的位置

[英]jQuery UI Dialog Box Position

我的表格比屏幕高度高。 用戶提交表單后,會彈出一個對話框,並通過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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM