Bootstrap彈出框(Popover)被擠壓的問題小結(jié)
比較了下Bootstrap的popover和一些其它的開源項(xiàng)目,覺得Bootstrap的還算不錯。沒想到第一次就遇到了一個問題。
彈出框顯示的時候如果貼近一個列的邊沿,就會很窄,如果一個列比較寬還好,而如果遇到這樣的列比如:<div class="col-md-2">
,幾乎任意位置顯示的彈出框都被擠壓了。
先看看我的實(shí)現(xiàn)以及效果:
js:
$(function (){ $("[data-toggle='popover']").popover({ trigger: 'hover' }); });
html:
<div class="col-md-1"> ... <img src="..." width="50" height="50" data-toggle="popover" data-content='...' title="..." /> ... </div>
效果
不過解決起來很簡單,只需在初始化的時候添加一個container屬性就可以了:
$(function (){ $("[data-toggle='popover']").popover({ trigger: 'hover', container: 'body' }); });
我們把容器設(shè)置成整個頁面的body,這樣popover就有足夠?qū)挼牡胤搅恕?/p>
實(shí)際上在官網(wǎng)上對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)被擠壓的問題小結(jié),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
layui-table獲得當(dāng)前行的上/下一行數(shù)據(jù)的例子
今天小編就為大家分享一篇layui-table獲得當(dāng)前行的上/下一行數(shù)據(jù)的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09詳解ES6 Fetch API HTTP請求實(shí)用指南
本次將介紹如何使用Fetch API(ES6 +)對REST API的 HTTP請求,還有一些示例提供給大家便于大家理解。具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-11-11