iframe 在 android 2.3.6 上无法调整大小

发布于 2025-01-05 02:13:58 字数 773 浏览 4 评论 0原文

我通过通用嵌入代码在页面上有一个 Vimeo 视频:

<div class="video">
  <iframe src="http://player.vimeo.com/video/VIDEO_ID" width="100%" height="100%" frameborder="0"></iframe>
</div>

我正在使用 Vimeo 的 JavaScript API (http ://vimeo.com/api/docs/player-js)向 video div 添加一个类(使 div 加倍),以便在视频开始播放时以及在视频暂停或结束,课程被删除,将视频播放器大小重置为其原始大小。

这在台式机/笔记本电脑 (Firefox) 上按预期工作,但在 Android 手机上,iframe(一旦其大小加倍)不会返回到之前的大小(它是一个百分比,因此它应该适应其 video 容器),这会导致 iframe 与其父 div 重叠。

首先我以为是 iframe 的 100% 宽度和高度,所以我使用 $('#video1').attr('width', 400); 为 iframe 指定了固定的宽度和高度; 当视频停止时,但 iframe 保持不变(大小保持两倍)。

有谁知道 Android 为什么这样做以及如何强制 iframe 调整大小?

I have a Vimeo video on a page via the universal embed code:

<div class="video">
  <iframe src="http://player.vimeo.com/video/VIDEO_ID" width="100%" height="100%" frameborder="0"></iframe>
</div>

I'm using Vimeo's JavaScript API (http://vimeo.com/api/docs/player-js) to add a class to the video div (that doubles the div) for when the video starts playing, and when the video is paused or finishes, the class is removed, resetting the video player size to its original size.

This works as expected on a desktop/laptop (Firefox), but on an Android phone, the iframe (once it doubles its size) doesn't return to its previous size (it's a percentage, so it should adapt to its video container), which causes the iframe to overlap its parent div.

First I thought it was the 100% width and height of the iframe, so I specified a fixed width and height for the iframe using $('#video1').attr('width', 400); when the video is stopped, but the iframe remained unchanged (it stayed double the size).

Does anybody have any ideas of why Android does that and how can I force the iframe to resize?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文