【问题标题】:Bootstrap Popover in Sidebar侧边栏中的 Bootstrap 弹出框
【发布时间】:2015-01-11 09:30:12
【问题描述】:

我想以这样一种方式使用 Bootstrap 的弹出窗口功能,使窗口在侧边栏中打开,而不是与触发按钮/文本相邻,但我不知道它是如何工作的。我尝试为侧边栏提供一个 ID,并包含属性 data-viewport="#sidebar" 但这似乎不起作用。
我是一名试图为我的班级做点事情的老师,而不是程序员或其他任何东西,所以任何帮助都将不胜感激。
这是我正在寻找的模型:http://i.imgur.com/IYPFlOC.jpg

这是我所拥有的:

  <div class="container">
    <div class="row">
        <div class="col-sm-4">
            <div id="sidebar">
                Sidebar where the popup window should appear.
            </div>
        </div>

        <div class="col-sm-8">

            <p>This is the main content where the <span class="pop"
            data-content="Popover Content" data-html="true" data-toggle=
            "popover" data-trigger="hover" tabindex="0" title=
            "Title">trigger text</span> would be.</p>
        </div>
    </div>
</div>

【问题讨论】:

    标签: twitter-bootstrap popover


    【解决方案1】:

    这是一个粗略的例子,说明我认为您正在努力实现的目标。

    JSFiddle:Example Code

    <div class="container">
    <div class="row">
        <div class="col-sm-4">
            <div id="sidebar">
                Sidebar where the popup window should appear.
    
                <span data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Sidebar where the popup window should appear.</span>
            </div>
        </div>
    
        <div class="col-sm-8">
    This is the main content where the
            <a id="btn">trigger text</a>
            would be.
        </div>
    </div>
    

    $(function () {
        $("#btn").on("click", function(){
            $('[data-toggle="popover"]').popover("toggle")
        });
    });
    

    【讨论】:

    • 看起来越来越近了,但不是我的想法。这不适用于多个弹出窗口,对吗?我在原始帖子中添加了一张图片,以便更好地了解我的目标。
    • 您是否设置为此使用引导弹出窗口?我认为自定义函数可以更好地处理这个问题。
    • 不,我根本不打算使用弹出框。我喜欢它在翻转时显示注释的方式,但只是想以不同的方式定位注释。如果我能以另一种方式实现这一目标,我会喜欢任何指针。
    • 我更新了答案中的“示例代码”。您可以在其中添加自己的样式以自定义外观。
    • 太棒了!谢谢克莱顿,我真的很感激。我会玩这个。
    猜你喜欢
    • 1970-01-01
    • 2014-07-03
    • 2023-03-30
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 2013-08-11
    • 1970-01-01
    • 2015-03-27
    相关资源
    最近更新 更多