twitter-bootstrap 如何将引导程序数据容器设置为特定 id
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23637340/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set bootstrap data-container to particular id
提问by user3608168
I tried to make bootstrap popover,for that I written the following code as per bootstrapguide.
我试图制作bootstrap popover,为此我按照bootstrap指南编写了以下代码。
I am using bootstrap 3.1.0.
我正在使用bootstrap 3.1.0.
<input id="shelfLifeField" type="text" placeholder="Use-By" class="form-control first" data-container="body" data-toggle="popover" data-placement="bottom" data-html="true" data-content="<div class='row'>this is just for text</div>"/>
it's working fine but the problem was popover contentappending to body.For this I read bootstrapdocumentation finally I find, I can control through data-containerattribute.
它工作正常,但问题popover content附加到body.为此,我bootstrap最终阅读了文档,我发现,我可以通过data-container属性进行控制。
so I tried with the following way.
所以我尝试了以下方式。
data-container="#anotherDivId"
Actually what I am trying,I want to append popovercontent to specific div("anotherDivId") instead of appending to body.
实际上我正在尝试的是,我想将popover内容附加到特定的div(“anotherDivId”)而不是附加到body.
I failed with my idea so can anyone help me.
我的想法失败了,所以任何人都可以帮助我。
Thanks.
谢谢。
回答by Sébastien Nussbaumer
data-container="#anotherDivId"is right and should work.
data-container="#anotherDivId"是正确的,应该工作。
Be careful though that if #anotherDivId is hidden (with display:none), then the popover won't work
但请注意,如果 #anotherDivId 被隐藏(使用 display:none),则弹出框将无法工作

