在商城里,導航欄的購物車展示經常需要鼠標經過時,顯示已經放入購物車的商品,bootstrap是沒有直接用的插件的,這個時候就可以使用popover這個插件改造后實現,具體如下:
實現效果圖:
html實現:
<a href="#" rel="drevil"><span class="glyphicon glyphicon-shopping-cart"> </span> 購物車</a>
javascript實現:
$(function(){$("[rel=drevil]").popover({trigger:'manual',placement : 'bottom', //placement of the popover. also can use top, bottom, left or righttitle : '<div style="text-align:center; color:red; text-decoration:underline; font-size:14px;"> Muah ha ha</div>', //this is the top title bar of the popover. add some basic csshtml: 'true', //needed to show html of coursecontent : '<div id="popOverBox"><img src="http://www.hd-report.com/wp-content/uploads/2008/08/mr-evil.jpg" width="251" height="201" /></div>', //this is the content of the html box. add the image here or anything you want really.animation: false}).on("mouseenter", function () {var _this = this;$(this).popover("show");$(this).siblings(".popover").on("mouseleave", function () {$(_this).popover('hide');});}).on("mouseleave", function () {var _this = this;setTimeout(function () {if (!$(".popover:hover").length) {$(_this).popover("hide")}}, 100);});});
以上所述是小編給大家介紹的BootStrap使用popover插件實現鼠標經過顯示并保持顯示框,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
新聞熱點
疑難解答