gpt4 book ai didi

html - 移动设备上的 Youtube iframe,宽度不佳

转载 作者:太空宇宙 更新时间:2023-11-04 01:40:56 27 4
gpt4 key购买 nike

我的页面 zaybee.pl 上有关于 youtube iframe 的问题,当你用 youtube 查看帖子中的小窗口时,一切正常 - youtube 宽度更改为窗口宽度:

View on small windows on computer

但在手机(Android、Google Chrome)上,iframe 比网页的其余部分大:

enter image description here

页面上的其余元素具有良好的宽度。在桌面测试人员上,页面在移动设备上的外观如何,一切看起来都不错。我不知道问题在哪里。

我的代码片段:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>

<div class="ytframe"><iframe width="100%" height="364" style="position:relative;z-index:100;" src="http://www.youtube.com/embed/'.$src['v'].'?wmode=transparent" frameborder="0" allowfullscreen></iframe></div>

.ytframe {width:calc(100% - 77px);height:400px;position:relative;}

最佳答案

您可以使用此 CSS 使 YouTube iframe 在移动设备和 ipad 上响应

.iframeVideo {
height: 0px;
padding-top: 25px;
padding-bottom: 56.2%;
position: relative;
}
.iframeVideo iframe {
width: 100%;
height: 100%;
position: absolute;
}
<div class="iframeVideo">
<iframe src="https://www.youtube.com/embed/Jiji_1iosv4" frameborder="0" allowfullscreen></iframe>
</div>

关于html - 移动设备上的 Youtube iframe,宽度不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45413689/

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