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

General Discussion

Video 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

You 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

fixed for readability. :)

Thanks Jason

Thanks Joel and Jason, let me look into that.