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

后端 未结 6 1774
渐次进展
渐次进展 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条回答
  •  Happy的楠姐
    2021-02-03 11:37

    You can also do this: Place the video element in the center with left and top of 50%, then translate it back with transform: translate(-50%, -50%);, finally give it a min-height and min-width of 100%

    video {
      left: 50%;
      min-height: 100%;
      min-width: 100%;
      position: fixed;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    

提交回复
热议问题