简体   繁体   中英

Video Background not playing properly on Safari

Video background is not playing properly on Safari. It shows up on the bottom right of the screen which is not quite good to look at. But this works great on Chrome.

Here is the link .

Here is the HTML code:

<video autoplay  poster="" id="bgvid" loop>
  <!-- WCAG general accessibility recommendation is that media such as background video play through only once. Loop turned on for the purposes of illustration; if removed, the end of the video will fade in the same way created by pressing the "Pause" button  -->
<source src="http://devjentri.com/wp-content/uploads/2015/09/deW_vid_final_.webm" type="video/webm">
<source src="http://devjentri.com/wp-content/uploads/2015/09/deW-vid-final-.mov" type="video/mp4">
</video>

CSS Code:

video { 
    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-size: cover;
    transition: 1s opacity;
}

You need to add the vendor prefix version of the transform to your CSS rule:

-webkit-transform: translateX(-50%) translateY(-50%);

The complete rule should look like this:

video { 
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    -webkit-transform: translateX(-50%) translateY(-50%);
    transform: translateX(-50%) translateY(-50%);
    background-size: cover;
    transition: 1s opacity;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM