我希望弹出框始终保持在同一位置,并且在滚动时不会改变: https://jsfiddle.net/eloyrubio/aq9Laaew/251011/
var options = {
placement: 'top',
title: 'I should be on top',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque lobortis nisl et metus varius lobortis. Sed sit amet posuere velit. Curabitur vel blandit mauris, a rutrum ante. Praesent sit amet orci viverra arcu sodales posuere.',
html: false
};
$('#po1').popover(options).popover('show');
我正在使用Bootstrap 4.1.3,并且看到Popover扩展了Tooltip: https://github.com/twbs/bootstrap/blob/v4-dev/js/src/popover.js#L70
这是工具提示代码: https://github.com/twbs/bootstrap/blob/v4-dev/js/src/tooltip.js
答案 0 :(得分:1)
您应该添加fallbackPlacement
的另一个选项:
var options = {
placement: 'top',
fallbackPlacement: ['top'],
flip: 'top',
title: 'I should be on top',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque lobortis nisl et metus varius lobortis. Sed sit amet posuere velit. Curabitur vel blandit mauris, a rutrum ante. Praesent sit amet orci viverra arcu sodales posuere.',
html: false
};
它将该值传递给flip.behavior
(see more)。