這邊我們用到position這個參數,設定值如{}內所示:
position: { my: "center-50% center-80%", at: "center center", of: window } //設定出現位置
預設值是:position: { my: "center center", at: "center center", of: window }
這邊可以解釋為
my 視窗跳出來的位置 中間center(左右)、中間center(上下)
at 對準 中間center(左右)、中間center(上下)
of window 整個視窗
完整範例程式碼:
//----------------------------------------
DlgMsgTips = $( ".DlgMsgTips" );
$("#DlgMsg").dialog({
autoOpen: false,
height: 200,
width: 260,
top: 0,
modal: true,
position: {
my: "center-50% center-50%",
at: "center-25% center",
of: window
},
buttons: {
"確定": function() {
$( this ).dialog( "close" );
}
// ,
// "取消": function() {
// $( this ).dialog( "close" );
// }
},
close: function() {
firstTips01(DlgMsgTips, "");//還原警示訊息
}
});
//----------------------------------------
參考資料:
https://lmcmultimedia.blogspot.com/2017/09/jquery-ui-dialog-box.html
期待您的留言

Comments