Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript “定位jQuery”对话框_Javascript_Jquery - Fatal编程技术网

Javascript “定位jQuery”对话框

Javascript “定位jQuery”对话框,javascript,jquery,Javascript,Jquery,我已经尝试了一百万种解决方案,但似乎都不管用。我只需要将jQuery对话框从页面顶部推大约50px。你知道怎么做吗 function message() { $("#message").dialog({ title: 'Title here', draggable:false, minHeight:100, resizable: false }); } 这里有一个参数,它接受一个X和Y坐标的数组: function mess

我已经尝试了一百万种解决方案,但似乎都不管用。我只需要将jQuery对话框从页面顶部推大约50px。你知道怎么做吗

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  
    });
}
这里有一个参数,它接受一个X和Y坐标的数组:

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

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

你试过这个吗?css代码.myPosition

和jquery

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

你试过这个吗?css代码.myPosition

和jquery

$('.selector').dialog({ dialogClass: 'myPosition' });
和adeneo一样,dialog有一个位置选项,可以接受一些数据类型,包括jQueryUI的花式

考虑到所有选项,我认为指定您想要的位置的最干净、最清晰的方法如下:

var myPos = { my: "center top", at: "center top+50", of: window };
和adeneo一样,dialog也有一个position选项,可以接受一些数据类型,包括jQueryUI的fancy

考虑到所有选项,我认为指定您想要的位置的最干净、最清晰的方法如下:

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

试试看

它仍然有点偏离中心。。不管怎样,我想我可能已经把它打开了。打开事件打开:函数事件,ui{$event.target.closest.ui对话框.css'top','50px';}它仍然有点偏离中心。。我想我可能已经把它打开了。打开事件:函数事件,ui{$event.target.closest'.ui dialog'.css'top',50px';}