How can I make HTML 5 video playback fit to frame instead of maintaining aspect ratio?

后端 未结 6 1820
渐次进展
渐次进展 2021-02-03 11:14

I\'ve been experimenting with HTML5 video playback. For example I have this video object embedded on my page:

6条回答
  •  眼角桃花
    2021-02-03 11:56

    I tried image-fit, but failed.

    then by checking above answers, I use object-fit in CSS:

    video {
      object-fit: fill;
    }
    

    From MDN (https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit):

    The object-fit CSS property specifies how the contents of a replaced element should be fitted to the box established by its used height and width.

    Value: fill

    The replaced content is sized to fill the element’s content box: the object’s concrete object size is the element’s used width and height.

提交回复
热议问题