gpt4 book ai didi

jquery - 使用qtip2时如何判断tooltip是向上还是向下?

转载 作者:行者123 更新时间:2023-11-28 12:32:43 26 4
gpt4 key购买 nike

我想在工具提示向上打开时更改工具提示位置。

qtip2初始化;

jQuery('.tip').each(function(){
jQuery(this).qtip({
position: {
at: 'center center',
my: 'top center',
adjust: {
y: 15,
method: 'shift flip'
},
viewport: $(window)
},
show: { delay: 500 },
hide: { fixed: true, delay: 300, leave: false }
});
});

我的初始化代码如上,当鼠标悬停在元素上时,它显示如下的向下工具提示;

enter image description here

没关系,但是向上工具提示如下所示

enter image description here

我希望它像这样显示;

enter image description here

我怎么可以?

http://jsfiddle.net/crLqm851/2/

最佳答案

在我看来,在这种情况下,flip 是一个错误的选择。使用 flipinvert 而不是 flip 使位置正确:

adjust: {
y: 15,
method: 'shift flipinvert'
}

当根本没有定义 method 时,它也会正确定位:

adjust: {
y: 15
}

fork fiddle -> http://jsfiddle.net/v68su257/

docs说:

The default "flip" type basically flips the tooltip when it goes off-screen i.e. from top-right, to bottom-right etc. The "flipinvert" type works the same way, except when the flip happens it inverts the adjust.x and adjust.y properties.

关于jquery - 使用qtip2时如何判断tooltip是向上还是向下?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28339998/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com