【发布时间】:2026-02-07 15:55:02
【问题描述】:
我在使用 Bootstrap 4.6 进行弹出框可视化时遇到问题
在这个最小的例子中:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>
</head>
<body style="background-color: cadetblue; height:1000px">
<header style="height: 100px">
</header>
<section style="overflow-y: auto; height: 500px; background-color: cornsilk;">
<div style="height: 1000px" > </div>
<div id="test">
<button type="button"
data-placement="top"
data-toggle="popover"
title="Blah"
data-content="Bleh Bleh">Blih</button>
</div>
<script>
$("button").popover({})
</script>
<div style="height: 1000px" > </div>
</section>
</body>
</html>
当按钮在滚动中可见时,弹出框会正确显示:
但是,如果我滚动并且按钮“通过”“cadetblue”区域的弹出框,而不是保持滚动并最终停止可见,则停留在顶部/底部边界:
Popover stays in the "upper limit" when scrolling the section down
Popover stays in the "lower limit" when scrolling the section up
我试过摆弄container、boundary 和fallbackPlacement 选项,因为类似问题的一些答案表明,但无济于事。从我在这个网站和其他网站上的调查来看,Bootstrap 4.6 中的弹出窗口可视化是一个棘手的问题,但由于这是一个如此简单的问题,我确信我忽略了一些东西。
【问题讨论】:
标签: css twitter-bootstrap bootstrap-4