【问题标题】:Youtube embed not workingYoutube 嵌入不工作
【发布时间】:2018-06-13 01:10:58
【问题描述】:

Youtube 嵌入代码不起作用,如何解决这个问题?

https://fiddle.jshell.net/prabu0301/pLwz2bnx/3/

【问题讨论】:

  • 查看浏览器的调试控制台。错误说明了什么?

标签: html iframe


【解决方案1】:

事实证明,您在<iframe> 中使用了错误 src。你应该使用

https://www.youtube.com/embed/Foayrk4V5b4?&autoplay=1 

而不是

http://www.youtube.com/embed/Foayrk4V5b4?&autoplay=1

https:// 是问题所在。

/* --- RESPONSIVE VIDEO --- */

.embed-container {
  position: relative;
  padding-bottom: 56.25%;
  /* 16/9 ratio */
  padding-top: 30px;
  /* IE6 workaround*/
  height: 0;
  overflow: hidden;
}

.embed-container iframe,
.embed-container object,
.embed-container embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
}


/* --- This isn't needed, but helps demonstrate the "responsiveness" --- */

.wrapper {
  width: 90%;
  margin: 0 auto;
}
<div class="wrapper">
  <h1>Scale Me - Responsive Video</h1>

  <div class="embed-container">
    <iframe allowfullscreen="" frameborder="0" scrolling="no" src="https://www.youtube.com/embed/Foayrk4V5b4?&autoplay=1"></iframe>


  </div>

</div>

【讨论】:

  • 我的回答对您有帮助吗?为什么不呢?
猜你喜欢
  • 2012-04-07
  • 2015-05-23
  • 2018-01-09
  • 1970-01-01
  • 2020-07-03
  • 2012-10-24
  • 2014-02-17
  • 2011-02-04
  • 2012-12-25
相关资源
最近更新 更多