Youtube视频作为网页的背景

时间:2017-04-29 05:05:41

标签: html css video youtube background

我需要youtube视频作为我的网页的背景。 这是我的代码

<section class="about-section">

           <div class="video-background">
<div class="video-foreground">
  <iframe src="https://www.youtube.com/embed/UY9V5S9MEgk?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&playlist=W0LHTWG-UmQ" frameborder="0" allowfullscreen></iframe>
</div> </div> </section>

这很好用。我的问题是我需要使用以下youtube视频作为我的背景,但它无法正常工作。 我试过这两个网址但没有工作

  

https://youtu.be/UY9V5S9MEgk

Theese是我尝试过的网址

  

https://www.youtube.com/watch?v=UY9V5S9MEgk

4 个答案:

答案 0 :(得分:1)

复制youtube视频的嵌入代码,并将其替换为当前的

<iframe width="854" height="480" src="https://www.youtube.com/embed/UY9V5S9MEgk?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&playlist=W0LHTWG-UmQ" frameborder="0" allowfullscreen></iframe>

答案 1 :(得分:1)

试试这个:

<div style="position: fixed; z-index: -99; width: 100%; height: 100%">
  <iframe frameborder="0" height="100%" width="100%" 
    src="https://youtube.com/embed/UY9V5S9MEgk?autoplay=1&controls=0&showinfo=0&autohide=1">
  </iframe>
</div>

答案 2 :(得分:0)

这个问题已经解决[点击这里] [1]

如果您有任何疑问,请给我留言。

[1]: https://codepen.io/dudleystorey/pen/PZyMrd

和[点击这里] [1]

  [1]: https://www.labnol.org/internet/youtube-video-background/27933/

答案 3 :(得分:0)

试试这个:

<section class="about-section">   
  <div class="video-background">
    <div class="video-foreground">
      <iframe src="https://www.youtube.com/embed/UY9V5S9MEgk" frameborder="0" allowfullscreen>
      </iframe>
    </div> 
  </div> 
</section>

<!DOCTYPE html>
<html>
<body>

<iframe width="420" height="345" src="https://www.youtube.com/embed/UY9V5S9MEgk">
</iframe>

</body>
</html>