Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 video controls on Android Chrome don't span full width of video in this simple page

Save this as an html file and load it up in Android Chrome:

<html>
<body style="overflow:hidden;transform: scale(0.5, 0.5);">
        <video controls>
            <source src="http://techslides.com/demos/sample-videos/small.mp4">
        </video>
</body>
</html>

It should look like this:

enter image description here

If you play around with it, you'll find that removing EITHER the overflow:hidden or the transform:scale will make the controls span the whole width of the video as expected. However the combination of these two styles makes any video controls incorrectly sized, as shown.

This question seems somewhat related and suggests adding a transform: translateZ(0) to the containing element, however adding that translation either to the existing transform on the body or onto a new containing div does not resolve the issue.

Is this a bug in Android Chrome? I don't understand why the conjunction of these two styles should affect video control width.

like image 319
alan Avatar asked Nov 15 '17 17:11

alan


People also ask

Does HTML5 video work on mobile?

What Is the HTML5 Video Tag? The `<video>` element is simply a tag used to embed video content in an HTML document. As of 2022 it is excellently supported across all modern browsers (both mobile and desktop), except for Opera Mini.

When implementing the HTML5 video element How do you ensure that?

In order to ensure that a video is accessible by all of the target browsers, you'll need to provide, at minimum, two different source elements for your video element. Example 1-5 shows an HTML5 web page with a video element containing two different video sources: one in H.


2 Answers

To change the width of the video player's native controls bar you can add following in the css:

  video::-webkit-media-controls-panel {
    width: 100%;
  }

Here is the good example of styling native controls. I hope this helps you.

like image 123
Rajan Patil Avatar answered Nov 14 '22 00:11

Rajan Patil


you can change the tag to something like this

<video width="100%" height="100%" controls>
        <source src="http://techslides.com/demos/sample-videos/small.mp4">
</video>
like image 35
Info Admired Avatar answered Nov 14 '22 01:11

Info Admired