Vimeo 嵌入不遵守最大高度

发布于 2025-01-10 21:29:48 字数 772 浏览 4 评论 0原文

我在尝试让响应式 Vimeo 嵌入与我的整体视觉设计配合使用时遇到了一个神秘的问题。我想要实现的是让 Vimeo 嵌入呈现与其下面的图像相同的效果;

HTML:

<div class="vimeo"><iframe src="https://player.vimeo.com/video/180293809?h=9f21a250ca" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>

CSS:

.vimeo {
  display: block;
  padding: 1vw;
  position:relative;
  max-width: 95vw;
  max-height: 72vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

上面渲染了高度为 0 px 的 div。然而,当我对图像做同样的事情时,它工作得很好。我还尝试将相同的 CSS 应用于内部 iframe,但它只是使 iframe 更大,同时将视频播放器渲染为邮票的大小。

I have a mysterious problem trying to get a responsive Vimeo embed to work with my overall sight design. What I'm trying to achieve is for the Vimeo embed to render the same as images below it;

HTML:

<div class="vimeo"><iframe src="https://player.vimeo.com/video/180293809?h=9f21a250ca" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>

CSS:

.vimeo {
  display: block;
  padding: 1vw;
  position:relative;
  max-width: 95vw;
  max-height: 72vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

The above renders the div with a height of 0 px. However, when I do the same thing with for example an image, it works just fine. I've also tried to apply the same CSS to the inner iframe, but then it instead just makes the iframe larger while rendering the video player the size of a postage stamp.

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

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

发布评论

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