简体   繁体   English

Bootstrap 弹出窗口不起作用

[英]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();
})

DEMO HERE

Note - I've also given width to div and specified data-placement attribute to place it properly.注意- 我还为div提供了宽度,并指定了data-placement属性以正确放置它。 Since div width was 100% by default, it will move popover to end and hence will not be visible on the screen.由于默认情况下div width100% ,它会将popover移动到结尾,因此在屏幕上将不可见。 You need to play around with these attributes.您需要使用这些属性。 Also, I've not seen anywhere, popover is used on div .另外,我没有在任何地方看到, popover上使用div Please go through few of their properties and suggestions mentioned in their official site请浏览他们official site提到的一些属性和建议

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM