[英]Bootstrap popover does not work
I want to toggle a popover when users hover their mouse in to a div.当用户将鼠标悬停在 div 上时,我想切换弹出窗口。 Is using popover with
div
possible or I am doing something wrong.是否可以将 popover 与
div
一起使用,或者我做错了什么。 My code:我的代码:
<div class="grid-item content-text" data-toogle ="popover" data-content="Lorem ipsum dolor sit amet" data-trigger="hover" id="intro">
<h3> INTRO</h3>
<p>Hover me</p>
</div>
I also ut these in $(document).ready() function:我也在 $(document).ready() 函数中使用了这些:
$(function () {
$('[data-toggle="popover"]').popover();
});
My js script is in order and i do have bootstrap.css at top of my head
tag我的 js 脚本是有序的,我的
head
标签顶部确实有 bootstrap.css
<script type="text/javascript" src="js/jquery-1.12.3.min.js" ></script>
<script type="text/javascript" src="js/bootstrap.min.js" ></script>
<script type="text/javascript" src="js/customScripts.js" ></script>
However, I think there is something wrong with my popover implementation.但是,我认为我的 popover 实现有问题。 I failed even with just
data-trigger = "focus"
.即使只有
data-trigger = "focus"
我也失败了。 I created a pen on codepen.io: http://codepen.io/ngp130895/pen/qZQJOJ我在 codepen.io 上创建了一支笔: http ://codepen.io/ngp130895/pen/qZQJOJ
Basically it was not identifying to which element
- popover
was attached, for reasons unknown.基本上它没有识别哪个
element
- popover
附加,原因未知。 But when I tried it with giving classname
of the div
it actually identified the element
.但是当我尝试给出
div
classname
时,它实际上识别了element
。
$(function() {
$('.grid-item').popover();
})
Note - I've also given width to
div
and specifieddata-placement
attribute to place it properly.注意- 我还为
div
提供了宽度,并指定了data-placement
属性以正确放置它。 Sincediv
width
was100%
by default, it will movepopover
to end and hence will not be visible on the screen.由于默认情况下
div
width
为100%
,它会将popover
移动到结尾,因此在屏幕上将不可见。 You need to play around with these attributes.您需要使用这些属性。 Also, I've not seen anywhere,
popover
is used ondiv
.另外,我没有在任何地方看到,
popover
上使用div
。 Please go through few of their properties and suggestions mentioned in theirofficial site
请浏览他们
official site
提到的一些属性和建议
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.