Before comments come out that this question has been asked several times, here an important aspect.
I dont't want the video element to keep the aspect ratio of the played video. I want the video element to always have an aspect ratio of 19:6, also if the played video has an aspect ratio of 21:9 or 4:3.
What I tried:
HTML:
<main>
<div class="main-container">
<div class="video-container">
<video class="video" controls="" src="..." poster="..."></video>
</div>
</div>
</main>
CSS:
main {
margin: 0;
padding: 0;
width: 100%;
height: calc(100% - 76px - 55px);
background: black;
}
main .main-container {
margin: 0 10%;
padding: 0;
width: 80%;
height: 100%;
background: black;
display: float-root;
}
main .main-container:after {
clear: both;
}
main .main-container .video-container {
margin: 0;
padding: 0;
width: 75%;
height: 100%;
float: left;
display: inline-block;
}
main .main-container .video-container .video {
margin: 25px 50px 25px 0;
padding: 0;
width: calc(100% - 50px);
max-height: calc(100% - 50px - 130px);
object-fit: contain;
outline: none;
}
JS:
window.addEventListener("resize", function(e) {
var video = document.getElementsByClassName("video")[0];
var width = video.offsetWidth;
var height = width * 0.5625;
video.style.height = height;
});