The video is in the header, and the proportions of the container is variable as the width is 100%, and the height is 65vh, and the video must cover the whole container by cropping top-bottom, or left-right.
I can do this by local video using: object-fit: cover
, but this is not working with YouTube iframe.
.wp-custom-header {
position: relative;
overflow: hidden;
width: 100vw;
height: 65vh;
}
.wp-custom-header video,
.wp-custom-header iframe {
/* may be video or iframe depends if the user uploads a video, or insert YouTube */
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
object-fit: cover;
}
<div id="wp-custom-header" class="wp-custom-header">
<iframe id="wp-custom-header-video" allowfullscreen="1" title="YouTube video player" src="https://www.youtube.com/embed/rzfmZC3kg3M?autoplay=1&controls=0&disablekb=1&fs=0&iv_load_policy=3&loop=1&modestbranding=1&playsinline=1&rel=0&showinfo=0&enablejsapi=1&origin=http%3A%2F%2Flocalhost&widgetid=1" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" width="1920" height="677" frameborder="0"></iframe><button type="button" id="wp-custom-header-video-button" class="wp-custom-header-video-button wp-custom-header-video-pause" style="z-index: 9999999;position: relative;">Play</button>
</div>