The aspect ratio technique of videos is a separate topic and the video has to be absolutely placed onto the area created by the padding-top trick. the parent can be relative or absolute but obviously if it is absolute it is removed from the flow.
There are also issues compounded by the padding technique because flex is shrink wrap and if you try to use a percentage width inside a flex item you can end up getting zero. That’s why in the original demo I cleaned up for you (many years ago now) I took all that into account and gave you the minimal structure to work with.
Use the flex rule I gave you it fixes it in one go.
I don’t think that its possible to change containera because of the aspect ratio technique. As soon as you remove the absolute positioning you lose the padding-top percentage and nothing shows. I believe we had a css grid version somewhere which got around this issue.
I think perhaps the easiest solution is to leave it as it is and perhaps put a min-height of 400px on the containera.
You have the solution with the fixed background anyway so why don’t you use that on both?
I believe I also gave you a solution with the nested div approach for containerb but containera can’t use that method so why not stick with the fixed background trick.
I think Code 3 is the one to go with here and I don’t think anything else needs to be done to the code except for adding the code that keeps the background covering the whole area.
You’d have to show me a page that you want it compared to but looking at that page you don’t seem to be setting a min-width on the ratio keeper so you never get any horizontal overflow. If the video was a fixed width this would happen.
However you could probably get around that (and we probably have already but I’ve lost track now)
Every change brings a slightly different behaviour and I think we are sometimes going around in circles back to issues that led us here in the first place.
I’d suggest that if this is your final design then it should be re-built from the ground up to simplify it and make it easier to manage. However if you are just contantly tweaking then there’s no point in rebuilding if you are going to change it again.
In that one the width is controlled by .inner that has a max and a min-width. You keep comparing apples and pears. Each one is slightly different and things are in place because of the differences. You need to have the same html before you can compare like for like.
I don’t really have to time today but I would suggest that you tidy up the html roughly like this into three distinct sections. (container a,b and c). Then you can show and hide each one and not have so many nestings in place You can then test each in isolation and check they are working.
This is the htmj l I would suggest but it may need to be changed if there are issues found.
The js of course is not working for the player as all the references are changed and that would need to be modified. I just hard coded the first one so that containera and containerb can be seen.
I would suggest that you test the html for this simpler version and then rearrange your js accordingly.
I am away for a week after tomorrow so that will give you time to make another hundred versions of it