Home  >  Article  >  Web Front-end  >  How to correctly set the width and height of video in html5

How to correctly set the width and height of video in html5

王林
王林forward
2021-01-25 10:28:435510browse

How to correctly set the width and height of video in html5

Usually we set it up like this:

(Learning video sharing: html video tutorial)

<video width="320" height="240" controls="controls">

But Sometimes it is found that the height of the video does not change after setting it. We can set the width and height of its parent element so that the video fills the parent element. Just add style="width= 100%; height=100%; object-fit: fill" to the video tag.

object-fit syntax

object-fit:fill | contain | cover | none | scale-down

object-fit value description

object-fit is mainly suitable for replacing elements, such as: 39000f942b2545a5315c57fa3276f220, a545301510d9f9978355a8a3a2d2172c, a1f02c36ba31691bcfe87b2722de723b, 0b8441e4390851031b18beb35bf01222, 486d7a50595533609bc98d44595dc670, 7e441d6a19e1baa5cd948308fc07d711, 49ee62822bf0c6386fbdcf36ecd91df0, etc. Its default value is fill. The description of the object-fill value is as follows:

fill: This value is the default value of boject-fit. The size of the replacement content is set to fill the content box of the element, that is, the content of the element is expanded to completely Fills the container's outer dimensions, even if this breaks its intrinsic aspect ratio.

contain: Replace the element content size to maintain the aspect ratio to fill the element content container, whose specific object size is parsed to the width and height of a containing element. That is, if you set an explicit height and width on the replacement element, this value will cause the content to be sized exactly at the fixed ratio, but still within the element dimensions.

cover: Replace the element content size to maintain the aspect ratio to fill the element content container, and its specific object size is parsed to cover the width and height of the entire element. That is, the replacement element content size maintains the aspect ratio, but changes the width and height so that it completely covers the content element.

none: The replaced element content does not resize to fit the container of the inner element, the content completely ignores any height and weight set on the element, and still displays within the element dimensions.

scale-down: When the content size is set to non or contain, it will cause the specific object to become smaller.

Related recommendations: html5 tutorial

The above is the detailed content of How to correctly set the width and height of video in html5. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete