Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Christopher Mlalazi
Front End Web Development Techdegree Graduate 17,305 PointsVideo As Background
Hi guys. Does anyone know if there is a lecture on how to use a video as background on a home page, just like we use background full image?
3 Answers
Joel Rivera
29,401 PointsYou can use the video tag
<video autoplay loop poster="example.jpg" id="bgvid">
<source src="example.webm" type="video/webm">
<source src="example.mp4" type="video/mp4">
</video>
And then the css would be like:
video#bgvid {
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
-ms-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
background: url(polina.jpg) no-repeat;
background-size: cover;
}
This is not fully implemented but sets you on the right direction.
Hopefully it helps. Good Luck
Joel Rivera
29,401 PointsThanks Jason
Christopher Mlalazi
Front End Web Development Techdegree Graduate 17,305 PointsThanks Joel and Jason, let me look into that.
jason chan
31,009 Pointsjason chan
31,009 Pointsfixed for readability. :)