bootstrap 的具有響應式特性的嵌入內容是可以使YouTube影片自適應,但對於如果除了內建以外的二個容器比較外其他的使用上就會有問題了,因此fitvids.js可以自定比例而也可依影片的比例自行等比縮放,非常方便
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  | <!DOCTYPE html> <html lang="en"> <head>  <meta charset="UTF-8">  <title>fitVids test 视频流响应式</title>  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fitvids/1.1.0/jquery.fitvids.min.js"></script>  <script type="text/javascript">  $(function(){  $('.huhu').fitVids();  });  </script>  <style type="text/css">  html, body { padding:0px; margin:0px;}  .huhu { padding:10%;}  iframe{max-width: 100%;}  .content{max-width: 100%;}  </style>  </head>  <body>  <div class="content">  <div class="huhu">  <iframe src="https://www.youtube.com/embed/xGrXISLgvec"></iframe>  <iframe class="fitvidsignore" src="https://www.youtube.com/embed/xGrXISLgvec" width="600px" height="600px"></iframe>  </div>  </div>  </body> </html>  | 
See the Pen fitvids.js-iframe影片自適應 by Jimmy_Wu (@Jimmy_Wu) on CodePen.
js bin展示開新視窗
