HTML5 Video scale modes?

前端 未结 5 1933
长情又很酷
长情又很酷 2020-12-23 17:52

I\'m trying to make a fullscreen HTML background, which is easy enough. But because HTML5 video get\'s resized to fit the container while maintaining aspect ratio, I can\'t

5条回答
  •  天命终不由人
    2020-12-23 18:14

    Another way to do this with CSS is to use the object-fit property. This works on video or img elements

    video {
        object-fit: cover;
    }
    

    http://caniuse.com/object-fit

    http://dev.opera.com/articles/css3-object-fit-object-position/

    This is only compatible in Chrome 31+ but is the simplest CSS solution and is a Candidate Recommendation.

提交回复
热议问题