禁用Boostrap 4 Popover中的翻转

时间:2018-10-17 07:56:56

标签: javascript jquery bootstrap-4 bootstrap-popover popper.js

我希望弹出框始终保持在同一位置,并且在滚动时不会改变: 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');

image

我正在使用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

1 个答案:

答案 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.behaviorsee more)。

请参阅工作示例:https://jsfiddle.net/aq9Laaew/251047/