微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Bootstrap弹出框Popover被挤压的问题小结

比较了下Bootstrap的popover和一些其它的开源项目,觉得Bootstrap的还算不错。没想到第一次就遇到了一个问题。

弹出框显示的时候如果贴近一个列的边沿,就会很窄,如果一个列比较宽还好,而如果遇到这样的列比如

,几乎任意位置显示的弹出框都被挤压了。

先看看我的实现以及效果

js:

rush:js;"> $(function (){ $("[data-toggle='popover']").popover({ trigger: 'hover' }); });

html:

rush:xhtml;">
...

效果

不过解决起来很简单,只需在初始化的时候添加一个container属性就可以了:

rush:js;"> $(function (){ $("[data-toggle='popover']").popover({ trigger: 'hover',container: 'body' }); });

我们把容器设置成整个页面的body,这样popover就有足够宽的地方了。

1C8A50ED-88B6-44AB-928B-DE0911386A60.png

实际上在官网上对container的作用是有说明的地址 ,只是没有注意到:

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.

以上所述是小编给大家介绍的Bootstrap弹出框(Popover)被挤压的问题小结。编程之家 jb51.cc 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐