这是代码的 fiddle :http://jsfiddle.net/dLPa8/
如果您向下滚动,就会看到从 YouTube 嵌入的视频。我需要它,它应该覆盖整个页面的高度和宽度。我的意思是它看起来应该有点像第一部分(在 fiddle 中)。
我试过这个:
<iframe src="http://www.youraddress.com" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0px;left:0px;right:0px;bottom:0px" height="100%" width="100%"></iframe>
在一定程度上解决了问题,但是使用上面的iframe
,视频会粘在页面顶部。如何使视频部分高度为整页高度?
最佳答案
这是一个 FIDDLE
<iframe id="video" src="//www.youtube.com/embed/5iiPC-VGFLU" frameborder="0" allowfullscreen></iframe>
$(function(){
$('#video').css({ width: $(window).innerWidth() + 'px', height: $(window).innerHeight() + 'px' });
// If you want to keep full screen on window resize
$(window).resize(function(){
$('#video').css({ width: $(window).innerWidth() + 'px', height: $(window).innerHeight() + 'px' });
});
});
关于html - 如何使 YouTube 嵌入式视频成为整页宽度的视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20182409/