Trouble adding video as background

Viewed 37

i've looked around online and have tried two different methods, however, both don't seem to be working.

I need to make a video cover a whole webpage background (i've done it like so) -

css -

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;
}

HTML -

  <video playsinline autoplay muted loop poster="img/videoframe.jpg" id="bgvid">
        <source src="https://streamable.com/kuuap9" type="video/mp4">
    </video>

This however doesn't load anything onto my website background... am i missing something here / is there a simpler solution?

another way i tried is, with no luck is -

CSS-

.fullscreen-bg {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
    z-index: -100;
}

.fullscreen-bg__video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

HTML-

<div class="fullscreen-bg">
    <video playsinline autoplay muted loop poster="img/videoframe.jpg" id="bgvid">
        <source src="https://streamable.com/kuuap9" type="video/mp4">
    </video>
</div>

Thanks in advance guys, any help would be much appreciated.

2 Answers

just you need download file or url has .mp4

and

#bgvid {
         width:100%;
         hight:100vh;
         position: absulote;
         z-index:-1;


}

Update your HTML with the following Code

<video controls playsinline autoplay muted loop poster="img/videoframe.jpg" id="bgvid">
    <source src="https://streamable.com/kuuap9" type="video/mp4">
    Your browser does not support the video tag.
</video>
Related