【问题标题】:Drag parent starting from its iframe child从其 iframe 子项开始拖动父项
【发布时间】:2012-08-08 10:13:06
【问题描述】:

我有这样的事情

<div draggable="true">
<iframe width="640" height="360" src="http://www.youtube.com/watch?v=dQw4w9WgXcQ?fs=1&amp;feature=oembed" frameborder="0" allowfullscreen="">
</iframe>
</div>

当我开始拖动时,我希望能够通过单击 div 上的任意位置(包括 iframe)来拖动整个 div。但是 iframe 不会级联事件。我还想保持与 youtube 视频的交互成为可能(播放、全屏等)。

有谁知道如何使用 html/css/js/jQuery 做到这一点?

【问题讨论】:

  • 哇,直到现在才意识到html5中有一个“可拖动”属性
  • 点击链接,你很烂
  • @GregGuida:我点击链接是因为你提到了它,你太烂了;)

标签: javascript jquery iframe drag-and-drop draggable


【解决方案1】:

这里你有一个你想要的近乎的例子......只需稍微修复它

#dra
{
    width:560px;
    height:315px;
    border:1px solid green;
    cursor:pointer;

}

#dra:hover iframe
{
    z-index:-1;position:absolute;
}

<div id="dra"><iframe  width="560" height="315" src="http://www.youtube.com/embed/T6s3d2wdXVg" frameborder="0" allowfullscreen></iframe></div> 
<script>
$( "#dra" ).draggable({stop: function() {

                $( "iframe" ).css('z-index','0');
            }});

</script>

【讨论】:

    猜你喜欢
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 2022-11-06
    • 2014-07-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多