jquery - 模式中的 Bootstrap 3 和 Youtube

标签 jquery css twitter-bootstrap youtube twitter-bootstrap-3

我正在尝试使用 Bootstrap 3 的模态功能来显示我的 Youtube 视频。它有效,但我无法点击 Youtube 视频中的任何按钮。

有什么帮助吗?

这是我的代码:

<div id="link">My video</div>

<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body">
                <iframe width="400" height="300" frameborder="0" allowfullscreen=""></iframe>
            </div>
        </div>
    </div>
</div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.10.1.min.js"><\/script>')</script>
<script src="js/bootstrap.min.js"></script>
<script>
    $('#link').click(function () {
        var src = 'http://www.youtube.com/v/FSi2fJALDyQ&amp;autoplay=1';
        $('#myModal').modal('show');
        $('#myModal iframe').attr('src', src);
    });

    $('#myModal button').click(function () {
        $('#myModal iframe').removeAttr('src');
    });
</script>

最佳答案

我发现这个问题(或我在 https://github.com/twbs/bootstrap/issues/10489 发现和描述的问题)与 .modal.fade .modal-dialog 类上的 CSS3 转换(翻译)有关。

在 bootstrap.css 中,您会发现如下所示的行:

.modal.fade .modal-dialog {
  -webkit-transform: translate(0, -25%);
      -ms-transform: translate(0, -25%);
          transform: translate(0, -25%);
  -webkit-transition: -webkit-transform 0.3s ease-out;
     -moz-transition: -moz-transform 0.3s ease-out;
       -o-transition: -o-transform 0.3s ease-out;
          transition: transform 0.3s ease-out;
}

.modal.in .modal-dialog {
  -webkit-transform: translate(0, 0);
      -ms-transform: translate(0, 0);
          transform: translate(0, 0);
}

用以下内容替换这些行将正确显示电影(在我的例子中):

.modal.fade .modal-dialog {
  -webkit-transition: -webkit-transform 0.3s ease-out;
     -moz-transition: -moz-transform 0.3s ease-out;
       -o-transition: -o-transform 0.3s ease-out;
          transition: transform 0.3s ease-out;
}

.modal.in .modal-dialog {

}

关于jquery - 模式中的 Bootstrap 3 和 Youtube,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18622508/

相关文章:

css - 仅 1 页 100% 宽度,其余部分保持流畅

Twitter Bootstrap 模态数据关闭

javascript - Kendo 中的过滤工具提示

javascript - 是否可以使用事件监听器而不是间隔来检查变量是否为特定值?

jquery - 我应该将单位 'px' 添加到 jQuery 的 css 函数中的数值吗?

jquery - Superfish 在 IE 6-9 中不工作

javascript - 值(value)更新的视觉反馈

jquery - 通过 Jquery 和 CSS 展开和折叠 Div

html - MVC 中的 CSS 样式显示不同的@Html.ActionLink 链接

jquery - bootstrap-datepicker 未选择输入上的更改事件