【问题标题】:Twitter Bootstrap: Modal popup won't fadeTwitter Bootstrap:模态弹出窗口不会消失
【发布时间】:2016-03-23 20:06:49
【问题描述】:

我使用 twitter 引导模式插件有以下标记:

    <div class="tabbable">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#tabPeople" data-toggle="tab">People</a></li>
            <li><a href="#tabRoles" data-toggle="tab">Roles</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane active fade in" id="tabPeople">
                <a data-toggle="modal" href="#modalEditPerson1">Name</a>
                <div class="modal hide fade in" id="modalEditPerson1">
                    <div class="modal-header">
                        <button class="close" data-dismiss="modal">
                            ×</button>
                        <h3>
                            Name</h3>
                    </div>
                    <div class="modal-body">
                        <p>
                            One fine body…</p>
                    </div>
                    <div class="modal-footer">
                        <a href="#" class="btn" data-dismiss="modal">Close</a> <a href="#" class="btn btn-primary">
                            Save changes</a>
                    </div>
                </div>                   
            </div>
            <div class="tab-pane fade" id="tabRoles">
                <p>
                    Role stuff here.</p>
            </div>
        </div>
    </div>

这会调出一个模态,但不会像本页演示中那样淡化它:http://twitter.github.com/bootstrap/javascript.html#modals

更新 我已经意识到问题在于它嵌套在一个也使用 .fade 的 .tabbable div 中 我已经更新了上面的html。

【问题讨论】:

    标签: twitter-bootstrap modal-dialog fade


    【解决方案1】:

    您可能忘记包含动画的 javascript

    <script src="assets/js/bootstrap-transition.js"></script>
    <script src="assets/js/bootstrap-modal.js"></script>
    

    transitions.js 需要首先包含在内!

    【讨论】:

    • 你是对的。我从github下载的,所以没有包含插件,但是现在我已经包含了它仍然不褪色。
    • 只需测试您的 html 即可。你确定你下载了正确的 bootstrap-transition.js 吗?
    • 在这个页面上:twitter.github.com/bootstrap/download.html 我选择了所有插件,然后点击底部的巨大蓝色按钮。
    • 我现在已经删除了相关的 html 并且它工作正常。当它嵌套在一个也会消失的 .tabbable 元素中时,它似乎是一个问题。关于如何克服的任何想法?请看上面更新的html
    • 只是一个注释,如果您从引导程序中选择性地包含各种 css 组件,您也必须在样式表中具有 .fade 样式。
    【解决方案2】:

    首先将您的模态弹出框放在body标签之外。在该注释之后或从bootstrap.css中的模态背景类中删除显示属性,就像我在下面所做的那样

    .

    modal-backdrop {
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      z-index: 1040;
      background-color: #000;
      /*display:none;*/
    now write some jquery as i have mentioned below:
    

    $("#Yourid").click(function() {
    
      $('.modal-backdrop fade in').attr("display", "block");
    });

    【讨论】:

    • 1.您不应将任何 HTML 代码放在 body 标记之外。
    • 2.不要修改源引导 css 文件。
    • 3.不需要javascript。
    • 4.该解决方案根本没有解决开头的帖子(不确定它应该实现什么)
    • 我遇到了问题并且没有找到解决方案,所以利用我的知识应用了这个逻辑,这个解决方案就像魅力一样。没有规则说你不能修改引导 css,主要是人使用自定义 css 修改或覆盖引导 css。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-23
    • 1970-01-01
    • 2021-05-19
    • 2012-01-12
    • 2012-01-17
    相关资源
    最近更新 更多