Iframe大小不正确

大家好!

我无法正确嵌入我尝试嵌入到主题中的 iframe。看它有多小!有人知道怎么解决吗?

提前感谢!

1 个赞

您需要将 iframe 的 widthheight 设置为绝对值。此外,宽度和高度需要设置为 iframe 的属性,而不是 style 属性(Discourse 在处理帖子时会移除 style 属性)。

下面是一个从 YouTube iframe 复制的示例,展示了如何操作:

<iframe width="560" height="315" src="https://www.youtube.com/embed/r-i6XpcL1Fs" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

我认为在 Discourse 帖子中可以使用的最大宽度是 600。您可以直接使用截图中的 iframe 代码,只需在 <iframe> 标签后添加 width="600" height="400" 即可。您可以尝试不同的宽度和高度值,看看哪个效果最好。

4 个赞

@simon 非常感谢!太管用了!节日快乐!

2 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.