scale HTML5 Video and break aspect ratio to fill whole site

后端 未结 9 2125
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 06:31

I want to use a 4:3 video as a background on a site, but setting the width and height to 100% doesnt work, since the aspect ratio is kept intact, so the video doesnt fill th

9条回答
  •  臣服心动
    2020-11-29 07:09

    http://dev.opera.com/articles/view/everything-you-need-to-know-about-html5-video-and-audio/

    [...] in the same way as the img element — if you only set one of width and height, the other dimension is automatically adjusted appropriately so that the video retains its aspect ratio. However — unlike the img element — if you set width and height to something that doesn't match the aspect ratio of the video, the video is not stretched to fill the box. Instead, the video retains the correct aspect ratio and is letterboxed inside the video element. The video will be rendered as large as possible inside the video element while retaining the aspect ratio.

提交回复
热议问题