2016-11-24 50 views
0

jQuery PopUp位置不工作。 流行边框和内容分离。JQuery PopUp位置不工作

尝试下面的代码

newDiv = $(document.createElement('div')); 
    $(newDiv).addClass("popup hide-scrol"); 
    newDiv.dialog({ 
     autoOpen: false, modal: true, show: "blind", hide: "blind" 
    }); 
    newDiv.html(response); 
    newDiv.dialog("option", "width", $(".render-body").width() * 0.5); 
    newDiv.position({ 
        my: "center", 
        at: "left", 
        of: ".container" 
        }); 

输出

enter image description here

回答

0

你试过吗?

newDiv.dialog("option").position({ 
    my: 'center', 
    at: 'left', 
    of: "#targetElement" 
}); 

和报价的JQuery Ui

的(默认:null)的API文档

类型:选择或元素或jQuery的或事件 哪个元素反对立场。如果您提供选择器或jQuery对象,则将使用第一个匹配元素。如果您提供事件对象,则将使用pageX和pageY属性。例如:“#top-menu”