jQuery UI对话框定位 [英] jQuery UI dialog positioning

查看:77
本文介绍了jQuery UI对话框定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 jQuery对话框UI 库,以便将对话框放置在旁边悬停时显示一些文本. jQuery对话框采用的位置参数是从当前视口的左上角开始测量的(换句话说,[0, 0]始终将其放置在浏览器窗口的左上角,而不管当前滚动到什么位置). ).但是,我知道检索位置的唯一方法是相对于整个页面的元素.

I am trying to use the jQuery dialog UI library in order to position a dialog next to some text when it is hovered over. The jQuery dialog takes a position parameter which is measured from the top left corner of the current viewport (in other words, [0, 0] will always put it in the upper left hand corner of your browser window, regardless of where you are currently scrolled to). However, the only way I know to retrieve the location is of the element relative to the ENTIRE page.

以下是我目前所拥有的. position.top的计算结果约为1200左右,这使对话框远低于页面上其余内容.

The following is what I have currently. position.top is calculated to be something like 1200 or so, which puts the dialog well below the rest of the content on the page.

$(".mytext").mouseover(function() {
    position = $(this).position();
    $("#dialog").dialog('option', 'position', [position.top, position.left]);
}

如何找到正确的位置?

谢谢!

推荐答案

查看一些jQuery插件,以获取对话框的其他实现. Cluetip 似乎是功能丰富的工具提示/对话框样式插件.第四次演示听起来与您要执行的操作类似(尽管我看到它没有您想要的精确定位选项.)

Check out some of the jQuery plugins for other implementations of a dialog. Cluetip appears to be a feature-rich tooltip/dialog style plug-in. The 4th demo sounds similar to what you are trying to do (although I see that it doesn't have the precise positioning option that you're looking for.)

这篇关于jQuery UI对话框定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆