Javascript 将Qtip保持在页面边界内?

Javascript 将Qtip保持在页面边界内?,javascript,Javascript,我正在侧边栏中使用QTip: 如您所见,QTip稍微偏离屏幕,在我的屏幕上创建了一个难看的hscrollbar 代码如下: function appendCalendarEventToList(className, event) { var eventObject = { title: event.title, id: event.id, type: event.type, color: event.color,

我正在侧边栏中使用QTip:

如您所见,QTip稍微偏离屏幕,在我的屏幕上创建了一个难看的hscrollbar

代码如下:

function appendCalendarEventToList(className, event) {

    var eventObject = {
        title: event.title,
        id: event.id,
        type: event.type,
        color: event.color,
        description: event.description,
        canReoccur: event.canReoccur,
        reoccurVal: event.reoccurVal,
        estHours: event.estHours
    };

    var div = document.createElement("div");
    div.className = 'external-event';
    div.style.background = event.color;
    div.innerHTML = event.title;

    // store the Event Object in the DOM element so we can get to it later
    $(div).data('eventObject', eventObject);

    $(div).draggable({
        helper: function () {
            $copy = $(this).clone();
            $copy.data('eventObject', eventObject);
            $copy.css({ "list-style": "none", "width": $(this).outerWidth() }); return $copy;
        },
        appendTo: 'body',
        zIndex: 999,
        revert: true,      // will cause the event to go back to its
        revertDuration: 0  //  original position after the drag
    });

    $(className).append(div);

   $(div).qtip({
        content: event.title,

        position:
            {
                target: 'mouse'
            },
        //  show: { event: 'click' },
        hide: { event: 'mousedown mouseleave' },
        style: {
            width: 200,
            padding: 5,
            color: 'black',
            textAlign: 'left',
            border: {
                width: 1,
                radius: 3
            },


            classes: {
                tooltip: 'ui-widget',
                tip: 'ui-widget',
                title: 'ui-widget-header',
                content: 'ui-widget-content'
            }
        }
    });


    return div;
}
现在,我想要的是,如果我能把它放在页面里面(如果(tip.right>page.right,tip.right=page.right))或者别的什么

有没有办法做到这一点

至少,我想确保它不会导致hscroll酒吧


谢谢

我有三个愚蠢的答案

  • 在qtip上使用
    position:fixed
    而不是
    position:absolute
  • 使用
    max width
    而不是
    width
    并定义
    right:0
    ,这样qtip的右侧将永远不会超过身体的最右侧
  • 试试我自己制作的jQuery工具提示插件(在这种情况下,告诉我你的想法)