javascript 定位 jQuery 对话框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15716317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Position jQuery dialog box
提问by tcovo
I've tried a million solutions and none seem to work. I just need to push my jQuery dialog box about 50px from the top of the page. Any ideas how?
我已经尝试了一百万个解决方案,但似乎没有一个奏效。我只需要将我的 jQuery 对话框从页面顶部推送大约 50 像素。任何想法如何?
function message() {
$("#message").dialog({
title: 'Title here',
draggable:false,
minHeight:100,
resizable: false
});
}
回答by adeneo
回答by tcovo
Like adeneo mentioned, dialog has a position
option which accepts a few data types, including jQuery-UI's fancy position object.
就像前面提到的adeneo 一样,对话框有一个position
选项可以接受一些数据类型,包括 jQuery-UI 的奇特位置对象。
Given all the options, I think the cleanest and clearest way to specify the position you want is like this:
鉴于所有选项,我认为指定您想要的位置的最干净,最清晰的方法是这样的:
var myPos = { my: "center top", at: "center top+50", of: window };
Try it in jsFiddle
在jsFiddle 中尝试
回答by Suresh Atta
Have you tried this? css code .myPosition
你试过这个吗?css代码.myPosition
.myPosition {
position: absolute;
top: 20px;
}
and jquery
和jQuery
$('.selector').dialog({ dialogClass: 'myPosition' });