bootstrap popover中参数容器的用法?

hlc*_*fan 10 javascript popover twitter-bootstrap bootstrap-popover

在大多数情况下,我发现在互联网上,container设置为'body'

我遇到了什么:

bootstrap popover显示在固定的div内容上,当你滚动页面时,popover也会移动.

我将param容器更改为我的特定DIV #search-filter-container,没有任何改变.

更新:

.popover即使我设定,现在DIV最终出现在体内container: '#some-my-div'

  <div class="popover fade right in" style="top: 429.5px; left: 680px; display: block;">
    code details...
  </div>
</body>
Run Code Online (Sandbox Code Playgroud)

Row*_*man 13

很难知道你在问什么,特别是因为你没有提供任何代码示例.请阅读我如何提出一个好问题?

但是,为了向您展示容器选项使用的示例,我创建了一个JSFiddle.

注释掉每行javascript以查看不同的效果(在结果框中向上和向下滚动).更改代码时不要忘记按Run.

HTML

<div style="height: 100px;">
    <br />Static text.</div>
<div style="position: fixed; width: 100%;" id="fixed-div">
    <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom" data-content="Vivamus
sagittis lacus vel augue laoreet rutrum faucibus." id="popover">Popover</button>
</div>
<div style="height: 2000px;"></div>
Run Code Online (Sandbox Code Playgroud)

使用Javascript

// comment this
$('[data-toggle="popover"]').popover({container: "body"});

// uncomment this
//$('[data-toggle="popover"]').popover({container: "#fixed-div"});
Run Code Online (Sandbox Code Playgroud)

  • 如果您想要解决问题,您必须更具体并包含代码.没有人可以帮助你*"没有工作"*. (2认同)
  • 对我来说似乎是个好问题。“这个记录不足的框架的目的是什么” (2认同)

Luc*_* C. 5

在容器属性中使用 CSS 选择器。

当所选容器滚动时,POLPOVER也将滚动,例如使用Opener按钮作为容器,或附近的元素

HTML

<button type="button" class="btn btn-primary" data-container="#popover-button" data-toggle="popover" ... id="popover-button">Open popover</button>
</div>
Run Code Online (Sandbox Code Playgroud)

爪哇脚本

$('#popover-button').popover({container: "#popover-button"});
Run Code Online (Sandbox Code Playgroud)