制作如下图所示的可点击工具提示的最佳方法是什么:
我应该使用 bootstrap 还是其他库?
Thanks.
干得好
$("#Pops").popover({
html: true,
content: function () {
return $('#popover-content').html();
}
});
[data-style=mypops] + .popover {
background: #4194ca;
}
[data-style=mypops] + .popover.bottom .arrow:after {
border-bottom-color: #4194ca;
}
[data-style=mypops] + .popover-content {
}
.popovermenu {
list-style: none;
padding: 0px;
margin: 0px;
}
.popovermenu li {
}
.popovermenu li a {
color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<div class="col-sm-4">
<button tabindex="0" class="btn btn-default" role="button" data-toggle="popover" data-trigger="focus" data-placement="bottom" data-style="mypops" id="Pops">Click Me</button>
<div id="popover-content" class="hide">
<ul class="popovermenu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
</div>
Edit:
- 添加了自定义
data-style="mypops"
在 popover 按钮中并添加 css,以便可以自定义 popover,而不会影响 bootstrap 中的默认 popover。
- 已更换
data-trigger="click"
with data-trigger="focus"
在弹出窗口按钮中,因此如果单击一个链接或在弹出窗口外部,弹出窗口将自动关闭。
Fiddle
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)