【发布时间】:2016-04-27 04:50:54
【问题描述】:
<!DOCTYPE HTML>
<head>
<style>
body {
overflow: hidden;
margin:0;
}
</style>
</head>
<body>
<iframe id="video" src="https://www.youtube.com/embed/U4c9bBeUe4M?modestbranding=1&showinfo=0" frameborder="0" allowfullscreen></iframe>
<script src="https://code.jquery.com/jquery-1.12.3.min.js" integrity="sha256-aaODHAgvwQW1bFOGXMeX+pC4PZIPsvn2h1sArYOhgXQ=" crossorigin="anonymous"></script>
<script>
$(function(){
$('#video').css({ width: $(window).innerWidth() + 'px', height: $(window).innerHeight() + 'px' });
$(window).resize(function(){
$('#video').css({ width: $(window).innerWidth() + 'px', height: $(window).innerHeight() + 'px' });
});
});
</script>
</body>
当我调整大小时,有没有办法让 iframe 随视频一起缩小?目前,当它调整大小时,有一个巨大的黑色间隙,视频位于中间。
【问题讨论】:
标签: javascript jquery html css youtube