gpt4 book ai didi

css - iframe 视频 100% 宽度

转载 作者:行者123 更新时间:2023-11-28 06:04:12 25 4
gpt4 key购买 nike

我正在尝试让 YouTube 视频以 100% 的宽度和高度显示。似乎 iframe 本身正在做我想要的,但是,一旦视频播放它只有 100% 宽度,最高 1100 像素。

我尝试在网上搜索但找不到使视频本身的宽度与视频海报和 iframe 宽度相同的解决方案。

最佳答案

试试这个:

.container {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%;
}
.video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class="container">
<iframe src="https://www.youtube.com/embed/ZLyS2wHiZM8"
frameborder="0" allowfullscreen class="video"></iframe>
</div>

Reference article

关于css - iframe 视频 100% 宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36564945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com