【发布时间】:2020-06-06 11:10:03
【问题描述】:
视频在标题中,容器的比例可变,宽度为100%,高度为65vh,视频必须通过上下裁剪或左右裁剪来覆盖整个容器。
我可以通过本地视频使用:object-fit: cover 执行此操作,但这不适用于 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>
【问题讨论】:
-
不是真的,这不是全屏视频,有固定位置,我正在尝试实现它,如果有结果我会回来
标签: css