As a user I want to be able to define a Youtube video to cover a certain container 100% both width a height. The proportions should be kept, so in some cases, the video is cut off.
I've tried with object-fit:cover, but when embeding the Youtube video as an iframe, the player is displayed perfectly with 100% width and height, but the video is scaled to fit the widht and then I get the black bars in the top & bottom.
Here's the PHP
else if($youtube_video AND is_admin() === false) {
echo '<div class="media-container ' . $shrink . ' ' . $mediaplacement . '">' .
'<iframe class="video" type="text/html" src="' . $youtube_video . '?autoplay=1&mute=1&loop=1&modestbranding=1&playsinline=1&rel=0" frameborder="0"></iframe>' .
'</div>';
}
And then the css
& .video{
object-fit: cover;
width:100%;
height:100%;
}
& .media-container{
position:absolute;
top:0;
right:0;
width:50%;
height:100%;
background-repeat: no-repeat;
I've also tried with this question Force iframe YouTube video to center fit and full cover the screen in the background using HTML5 CSS3
I just need the video looping, no controlls or play button.
object-fit: cover;
right. please post your html and css – Dejan.S