- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果您查看托管的 Bootstrap 演示 here然后向下滚动到包含所有 4 个按钮的演示。现在单击左侧的弹出窗口,它会正确显示。但是,当我缩小或扩展屏幕时,弹出窗口不再锚定到正确的点。有解决办法吗?
最佳答案
这与弹出窗口的容器属性有关。
http://jsfiddle.net/yvkhbw4b/1/
见附件示例。显示两个弹出框,然后将窗口从 xs 断点调整为 sm 断点。您会看到顶部项目将与按钮分开,因为容器默认为主体。 (我也通过选项将其设置为正文)。第二项附加到父 div,因此即使断点发生变化,第二项仍附加到该元素。
Documentation on popover options
Appends the popover to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize.
$('#btn1').popover({
'container': 'body'
});
$('#btn2').popover({
'container': '.col-sm-12'
});
可能的修复:您可以添加以下代码。目前仅处理底部对齐的弹出框,但您可以为其他对齐方式添加选项。
$(window).resize(function () {
$('.popover.in').each(function () {
var el = $('[aria-describedby="' + this.id + '"]');
if ($(this).hasClass('bottom')){
$(this).css('top',el.offset().top + el.outerHeight(true));
}
});
});
关于twitter-bootstrap-3 - 如何在 Bootstrap 3x 中正确锚定弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22813321/
我是一名优秀的程序员,十分优秀!