Full-width Background Videos in Internet Explorer

13,895

Solution 1

/*you can use this css.*/

.fullwidth-video {
position: absolute;
top: 0;
left: 0;
z-index: 1;
min-height: 100%;
min-width: 100%;
-webkit-transform-style: preserve-3d;
}
.fullwidth-video video {
position: absolute;
top: 0;
left: 0;
z-index: 1;
min-height: 100%;
min-width: 100%;
height: auto;
width: 100%;
object-fit: cover;
}

html code here...

     <div class="fullwidth-video">
     <video preload="auto" autoplay loop muted="">
       <source src="http://sawyerfirm.ignitte.com/wp-content/uploads/2015/12/Girl-Riding-In-Car-8-BW.mp4" type="video/mp4">
       <source src="http://sawyerfirm.ignitte.com/wp-content/uploads/2015/12/Girl-Riding-In-Car-8-BW.webm" type="video/webm">
     </video>
     </div>

Solution 2

You can Use this i hope it works for you :)

 This is html code :
 <div class="video-frame">
<video class="video-box" autoplay  poster="video-back.jpg" id="bgvid" loop>
<source src="sample.webm" type="video/webm">
<source src="sample.mp4" type="video/mp4">
</video>
</div>

This is css code :
.video-frame { position:relative;margin:40px auto;width:100%;}
.video-box { position: fixed; top: 50%; left: 50%; min-width: 100%; min-height: 100%; width: auto; height: auto; z-index: -100; transform: translateX(-50%) translateY(-50%); background: url('video-back.jpg') no-repeat; background-size: cover; transition: 1s opacity;}

Solution 3

SOLVED

I had same issue for width in IE: the solution i found is removing the additional custom css applied over the <video> tag.

This much code should work:

<!DOCTYPE html>
<html>

<body>

<video width="100%" height="" autoplay>
  <source src="http://sawyerfirm.ignitte.com/wp-content/uploads/2015/12/Girl-Riding-In-Car-8-BW.mp4" type="video/mp4">  
  Your browser does not support the video tag.
</video>

</body>

</html>

Then try to remove any additional class/style applied over/inside your tag

Solution 4

On IE set height to auto for video.

On Other Browsers:

.video {

    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100%;

    /* HTML video tag */
    &__player, video {

        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        object-fit: cover; /* IE not work */
    }
}

On IE:

.video {

    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100%;

    /* HTML video tag */
    &__player, video {

        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto; /* IE change to auto */
    }
}

And the HTML:

<div class="video">
    <video class="video__player" width="400" muted loop>
        <source src="XXX" type="video/mp4">
        Your browser does not support HTML5 video.
    </video>
</div>

Solution 5

object-fit: cover is not supported by IE. Use the following library, acts as a fallback for IE :

https://github.com/constancecchen/object-fit-polyfill

Share:
13,895
digitalJE5U5
Author by

digitalJE5U5

Updated on June 07, 2022

Comments

  • digitalJE5U5
    digitalJE5U5 almost 2 years

    I am designing a website that uses a self-hosted background video in a 100% width container. Works flawlessly in Chrome and Firefox but fails miserably in IE (tested in IE 11).

    The video is supposed to stretch width-wise to fill the container - maintaining the video proportions, however, IE simply places the video in the container at the size necessary to fill the container vertically.

    Screenshot of video stretching to fill container width in Chrome Screenshot of video failing to fill container in IE

    Link to Page with Error