I don’t see any vertical black lines. The black line at the bottom is the video itself.
You will get the odd 1px rounding error but I don’t see a big gap anywhere.
Again the problem is that you are trying to insert a different type of setup in a design that was made for something else so you end up with a lot of stuff that probably isn’t needed for this demo.
When you resize the window then at odd pixels the width and the height of the video will not be a perfect aspect ratio as one or the other of the pixel measurements is rounded up or down.
In reality this makes no difference unless you are trying to match it to a specific background as you are trying to do.
If you look at my demo above I changed the background so that it was gray and therefore you don’t get the odd black line showing when a rounding error occurs
You won’t see a black line with my code because there is no black. You didn’t post the code for that snippet so I can’t say what it is. In devtools set the iframe to opacity:0 and then you should see where the line is coming from (unless the line is part of the video itself).
I’m not at home this week so don’t have any other browsers to test on. However as there is no black under the video then the black must be a part of the video itself and beyond our control I expect.
I can’t actually see that white screen with a red button that you keep position. All I get is the screenshot I keep posting.
Nope can’t see it on my mac. Must be better at resizing.
It’s the video itself from the looks of it so I doubt there’s anything you can do. Try looking at other resizable videos on youtube and see if they do the same on our machine.
It doesn’t matter as they occupy the same space.
The contain value would likely make the video smaller but the cover value (object-fit:cover) may make it fill the area.
I also think the black is the background of the iframe showing through and it may help to explicitly make the background transparent.
e.g.
iframe {background:transparent;}
Or set it to the same colour as the background.
iframe {background:#bbb}
There is also the modern aspect ratio css property that could be used instead of the padding method.
However I don’t see any difference between the two on my browser and still expect this is a rounding issue that can’t be solved by normal means/
Actually I see all the youtube videos rounding slightly and a blurred edge showing. The youtube site doesn’t use iframes and I’ve no idea how they render their videos or what most of their custom html does. :). I think they have just coloured the background to mask the 1px rounding errors as I suggested above.
Youtube could even be monitoring the resize and adjusting the pixel measurements manually so that they always use the perfect 16:9 ratio. I do notice there is a noticeable delay on the youtube site when resizing.
You could also use an adaptive media query method and set the width and height of the video yourself to exactly 16:9 but you’d have to do it in jumps of say 100px otherwise you would need 640 media queries.
It all seems a lot of work for something that seems to happen on everybody’s site as far as I can tell.