当父div在屏幕上不可见时的jQuery UI位置函数问题 [英] jQuery UI position function problem when the parent div is not visible on the screen

查看:98
本文介绍了当父div在屏幕上不可见时的jQuery UI位置函数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用jQuery UI Position Function时遇到了一个奇怪的问题.

I'm facing a weird problem with jQuery UI Position function.

有一个父div,其大小大于屏幕的高度,而在其内部又有一个小div. 我的函数告诉小div位于父对象的底部.

There is a parent div, bigger then screen's height and another small div inside it. My function tell to the small div be positioned in the bottom of it parent.

当底部可见时,一切正常,但是由于窗口大小而底部不可见时,位置功能不起作用.

When the bottom is visible, everything is ok, but when the bottom is not visible because of the window size, the position function doesnt work.

遵循抽奖以方便理解...

Follow a draw to make easy understanding...

我正在使用的函数是

    $("#_GREEN_div").position({
        of: $("#_RED_div"),
        my: "left bottom",
        at: "left bottom"
    });

:JSFiddle- jsfiddle.net/Steve_Wellens/5Zdac (感谢史蒂夫,很棒的工具)

JSFiddle - jsfiddle.net/Steve_Wellens/5Zdac (thanks Steve, great tool)

推荐答案

我认为您还应该使用碰撞属性:

I think you should use collision attribute also:

$("#_GREEN_div").position({
    of: $("#_RED_div"),
    my: "left bottom",
    at: "left bottom",
    collision: 'none'
});

这样,"MY DIV"将始终位于左下角.

This way "MY DIV" will always be at the bottom left.

这篇关于当父div在屏幕上不可见时的jQuery UI位置函数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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