2012-06-27 30 views

回答

39

baptme的建議是好的,但更好的方法是指定您的popover標題,並且實際上將其完全隱藏,因爲邊距仍然存在,高度爲0.

.popover-title { display: none; } 

編輯:剛剛quicky看着源和似乎有一個未公開的選項:

$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, { 
    placement: 'right' 
    , content: '' 
    , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' 
    }) 

當你使用JS宣佈你的酥料餅,儘量覆蓋模板,並指定一個隱藏的稱號。

$('#example').popover({ 
    template: '...<h3 class="popover-title" style="display: none"></h3>...' 
}); 

我之所以說不要刪除它是它可能會導致運行時錯誤如果元素不存在。 查看Sherbrow的評論。

+0

如果酥料餅爲$(「#示例」)。酥料餅(選項),那麼什麼是CSS去這個元素的id,而不是所有酥料餅的頭銜? –

+0

彈出窗口元素在mouseover上創建並在mouseleave上銷燬。您無法專門定位該元素。查看我的編輯可能的解決方案 – Terry

+3

@Terry你可以刪除它,因爲它與jQuery選擇器一起使用:http://jsfiddle.net/Sherbrow/3GMnz/ – Sherbrow

1

簡單的方法是做設置height:0px在類.popover-title,並且不使用data-original-title

CSS:

.popover-title { height: 0px;} 
5

我使用@Terry和@Sherbow建議的技術組合結束了。顯示圖像,但不顯示標題(僅限於此彈出窗口)。

<a href="#" id="contributors" rel="popover">contributors</a> 

... 

<script> 
var contributor_img = '<img src="my_img/contributor.png" />' 


$(function() 
{ $('#contributors').popover({ 
    content: contributor_img, 
    template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><div class="popover-content"><p></p></div></div></div>' }); 
}); 
</script> 
0

您也可以編寫一個函數來刪除的元素:

function removeTitle(){ 
    $('.popover-title').remove(); 
} 

$("a[data-toggle=popover]") 
    .popover({ 
    html: true, 
    animation: true 
}) 
.click(function(e) { 
    removeTitle(); 
    e.preventDefault() 
}) 
相關問題