簡體   English   中英

定位jQuery對話框

[英]Position jQuery dialog box

我已經嘗試了上百萬種解決方案,但似乎都沒有用。 我只需要從頁面頂部推送約50px的jQuery對話框即可。 有什么想法嗎?

function message() {
    $("#message").dialog({
      title: 'Title here',
      draggable:false,
      minHeight:100,
      resizable: false  
    });
 }

有一個位置參數,它接受帶有X和Y坐標的數組:

function message() {
    var myPos = [ $(window).width() / 2, 50 ];

    $("#message").dialog({
      title: 'Title here',
      draggable:false,
      minHeight:100,
      position: myPos,
      resizable: false  
    });
}

小提琴

就像提到的 adeneo一樣,對話框有一個position選項,該選項接受一些數據類型,包括jQuery-UI的fancy position object

考慮到所有選項,我認為指定所需位置的最簡潔明了的方法是這樣的:

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

jsFiddle中嘗試

你有嘗試過嗎? CSS代碼.myPosition

.myPosition {
    position: absolute;
    top: 20px;
}

和jQuery

$('.selector').dialog({ dialogClass: 'myPosition' });

暫無
暫無

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

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