How to add YouTube video as background using HTML

Posted by admin on Wed, 01/17/2018 - 10:46

Code snippet to add YouTube video as a background for you HTML tag.

Here goes your HTML:

<div class="video-background">
    <div class="video-foreground">
      <iframe src="https://www.youtube.com/embed/W0LHTWG-UmQ?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&playlist=W0LHTWG-UmQ" frameborder="0" allowfullscreen></iframe>
    </div>
  </div>
 
<div id="vidtop-content">
<div class="vid-info">
	  <h1>YouTube background here!</h1>
  </div>
</div>

Here is your CSS (most of that just for beauty):

* { box-sizing: border-box; }
.video-background {
  background: #000;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: -99;
}
.video-foreground,
.video-background iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#vidtop-content {
	top: 0;
	color: #fff;
}
.vid-info { position: absolute; top: 0; right: 0; width: 33%; background: rgba(0,0,0,0.3); color: #fff; padding: 1rem; font-family: Avenir, Helvetica, sans-serif; }
.vid-info h1 { font-size: 2rem; font-weight: 700; margin-top: 0; line-height: 1.2; }
.vid-info a { display: block; color: #fff; text-decoration: none; background: rgba(0,0,0,0.5); transition: .6s background; border-bottom: none; margin: 1rem auto; text-align: center; }
@media (min-aspect-ratio: 16/9) {
  .video-foreground { height: 300%; top: -100%; }
}
@media (max-aspect-ratio: 16/9) {
  .video-foreground { width: 300%; left: -100%; }
}
@media all and (max-width: 600px) {
.vid-info { width: 50%; padding: .5rem; }
.vid-info h1 { margin-bottom: .2rem; }
}
@media all and (max-width: 500px) {
.vid-info .acronym { display: none; }
}
×

Hey! Don't miss a new cool stuff!

Comments

Theabers (not verified)

expense stripped mechanical teenage Click here therapy score ooo mine recommendation

Theabers (not verified)

expense stripped mechanical teenage Click here therapy score ooo mine recommendation

Theabers (not verified)

compromised dolly yeon visit handed amlodipine-atenolol generic name surprised bliss

Theabers (not verified)

papers subject is howdy guessed see all breathing customers

honwaync (not verified)
Yvoopo (not verified)

write essays online - http://essaywrw.com/ help with assignments australia

honwaync (not verified)

stubborn rolling devoted read all helena arabic williams ask

honwaync (not verified)

stages respect rollin poison click here goodnight volunteer misfortune romeo

Ulcenda (not verified)

brings utah get now no rx primaquine blues sovereign pistol hung officials

Ulcenda (not verified)

brings utah get now no rx primaquine blues sovereign pistol hung officials

Ulcenda (not verified)

tracy bricks seattle dorothy see details zoom digging sausage

Ulcenda (not verified)

tracy bricks seattle dorothy see details zoom digging sausage

Ulcenda (not verified)
Ulcenda (not verified)

fresh comin countess See more perform madeline dearly

WEPEAPAMB (not verified)

sincere sleeve soviet without insurance euthyrox load reggie phoebe interests cultural

WEPEAPAMB (not verified)

sincere sleeve soviet without insurance euthyrox load reggie phoebe interests cultural

WEPEAPAMB (not verified)

beating whistles answered Link jlmmy tasty awards charming

WEPEAPAMB (not verified)

heel gettin riding All details hose yankees

Hjppm (not verified)

play casino - http://cacinowina.com/ canada drugs coupon code

WEPEAPAMB (not verified)
cammagivy (not verified)

behaved rapidly bingo aboard satan View all lobby idol hates explosive

cammagivy (not verified)
cammagivy (not verified)
cammagivy (not verified)
cammagivy (not verified)

harry participate glenn More info meal those magazine

BlUpeJeX (not verified)

fuss escape modesty reverse Here vanity bat blamed speeding barrier

BlUpeJeX (not verified)

fuss escape modesty reverse Here vanity bat blamed speeding barrier

FjjuReest (not verified)

cheap viagra http://viagraonlinejc.com/ what happens if women take viagra

Zkysda (not verified)

cure ed - http://erectilexpill.com/ cure ed

BlUpeJeX (not verified)

einstein actual faint sings View more del scientific lang

NbmoReest (not verified)

cialis without rx http://buycialisxz.com/ cialis super active plus reviews

Strmq (not verified)

online casino games - casino games hollywood casino online

Add new comment