是否可以“隐藏”?图像背后的视频?
本质上,在页面加载时,我希望将视频隐藏在图像后面(我想这可以通过定位 div 来完成)。
我希望当用户单击视频隐藏在后面的图像时视频开始播放。这应该可以通过一些 JavaScript/CSS 实现。
我真正想问的是有谁知道这方面的任何例子,或者是否可以使用一些 jQuery/Mootools 扩展...?我不想使用 Flash,因此它可以在 iPhone/iPad 上运行。
谢谢
Essentially, on page load, I want a video to be hidden behind an image (I guess this can be done with positioning divs).
I would want the video to begin to play when a user clicks on the image the video is hidden behind. This should be possible with a bit of JavaScript/CSS.
What I'm really asking is does anyone know of any examples of this, or would it be possible with some jQuery/Mootools extension...? I would prefer not to use Flash so it works on iPhone/iPad.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这通常在嵌入 Quicktime 影片时完成。如果您能够设置其海报框架,则可以直接使用视频完成此操作。通常还通过将图像放置在屏幕上与视频相同的位置并在它们之间切换来完成。代码可能看起来像这样。
HTML
...
...
JS
function switchToVideo(){
document.getElementById('video' ).style.display = "block";
document.getElementById('poster').style.display = "none";
document.getElementById('video').播放();
}
This is normally done when embedding Quicktime movies. It can be done directly with the video if you are able to set its poster frame. It is also commonly done by placing an image on the screen in the same place as the video and switching between them. The code could look something like this.
HTML
...
<embed id="video" style="display: none;">...<embed>
<img id="poster" onclick="switchToVideo()">
...
JS
function switchToVideo(){
document.getElementById('video').style.display = "block";
document.getElementById('poster').style.display = "none";
document.getElementById('video').Play();
}
正如您所描述的(我不知道确切的语法),只需将具有更高 z 级别的图像放置在您想要隐藏的任何内容上,并在 JavaScript 中为其处理 onClick 方法即可。
As you described (I don't know the exact syntax), just place an image with a higher z-level over anything you want to hide and handle an onClick method for it in JavaScript.
为了使堆栈能够处理视频,您需要将 wmode 变量添加到对象/嵌入中。另外,要堆叠,您需要在要放置在另一个元素之上的元素上使用position:absolute。将它们都包含在一个相对容器中,并使 z-index 高于需要高于的容器。
以下是向视频添加 wmode 的示例:
In order for stacking to work with videos you will need to add the wmode variable to the object/embed. Also, to stack you will need to use position: absolute on the element that you want to place on top of the other. Contain them both in a relative container and make the z-index higher on the one that needs to go above.
Here is an example of adding wmode to the video: