Skip to content

Responsive local video helper #2509

Answered by mmistakes
tbullock asked this question in Q&A
Discussion options

You must be logged in to vote

There's no magic you need if you're using a standard HTML5 <video> element. You don't need any CSS either.

If you are using standard HTML5 video, that will make the video fit the width of the container. It’s important that you remove the height declaration when you do this so that the aspect ratio of the video is maintained as it grows and shrinks, lest you get awkward “bars” to fill the empty space (unlike images, the actual video maintains it’s aspect ratio regardless of the size of the element).

<video width="100%" ... ></video>

Or if you don't want to bother with adding width="100%" to each video element you can use the following CSS:

video {
  /* override other styles to make respo…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mmistakes
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2509 on December 22, 2020 15:26.