当鼠标悬停在元素上时,我使用自定义css类的PNotify提示:
tooltip = new PNotify({
title: false,
text: pin_text,
hide: false,
buttons: {
closer: false,
sticker: false
},
icon: false,
addclass: 'custom-tooltip',
history: {
history: false
},
animate: {
animate: true,
in_class: 'fadeIn',
out_class: 'fadeOut'
},
animate_speed: 'fast',
icon: false,
stack: false,
auto_display: false
});
var x = e.clientX + 25;
var y = e.clientY - 25;
tooltip.open();
tooltip.get().css({
'left': x,
'top': y
});
和CSS:
.ui-pnotify.custom-tooltip .ui-pnotify-container {
position: relative;
top: 0;
left: 0;
background: rgba(0,153,255,0.7) !important;
background-image: none !important;
border: none !important;
padding: 20px;
}
如果元素本身位于边界附近,则提示位于元素右侧25px处,并且超出父边界。
如何测量提示框(div)的宽度并将其方向从显示到右边交换显示到左边并仍然在父框架边界内?