Home > Web Front-end > H5 Tutorial > body text

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

不言
Release: 2018-08-08 11:34:20
Original
19171 people have browsed it

The content of this article is about how to set the width and height of the video tag in HTML5. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Generally:

Copy after login

But sometimes it is found that the height of the video has not changed after setting it. We can set the width and height of its parent element to fill the video 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 take Value description

object-fit is mainly suitable for replacing elements, such as: , , , , , and < ;svg:video>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 the content box of the filling element, that is, The element's content expands to completely fill 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, and its specific object size is parsed as 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 remains within the element Shown within dimensions.

  • scale-down: When the content size is set to non or contain, the specific object will become larger. Small.

Recommended related articles:

PostMessage in HTML5 implements cross-domain code analysis

video in HTML5 ( Analysis of video) elements

Analysis of audio (audio) in html5

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!