html - Facebook 页面嵌入的 iframe 不填充容器宽度

标签 html css facebook facebook-like

我添加了维基百科的 iframe 来演示我遇到的问题。
Wiki iframe 可以正常显示,但 facebook iframe 却不能。

enter image description here enter image description here

HTML:

   <div class="iframe-fb-container mt-4">
      <iframe class="iframe-fb" width="450" height="700" style="border:1px solid black;overflow:hidden" scrolling="yes" frameborder="0" allowTransparency="true" allow="encrypted-media" src="https://www.facebook.com/plugins/page.php?href=https://www.facebook.com/Microsoft/&tabs=timeline%2Cevents%2Cmessages&width=450px&height=700px&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId=2235597906716847"></iframe>
      <iframe class="iframe-fb" width="450" height="700" style="border:1px solid black;overflow:hidden" scrolling="yes" frameborder="0" allowTransparency="true" allow="encrypted-media" src="https://fr.wikipedia.org/wiki/Main_Page"></iframe>
   </div>

CSS:

.iframe-fb-container {
    border: 1px solid blue;
 }

 .iframe-fb {
    width: 100%;
    }

如您所见,我向 facebook 请求一个宽度为 450px 的 iframe,在所附的图片中,模拟器的宽度为 375px,但 fb iframe 仍然没有'像维基百科 iframe 一样填充它的容器。

如何让 fb iframe 填充它的容器?

最佳答案

您无法以正常方式做到 100%。

这是您的 iframe 源代码:

https://www.facebook.com/Microsoft/&tabs=timeline%2Cevents%2Cmessages&width=450px&height=700px&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId=2235597906716847"></iframe>

注意有一个参数:width=450px

它设置iframe内容的宽度为450px。

根据 Facebook Plugin documentation :

插件的像素宽度。分钟是 180 & 最大。是 500

所以Facebook能得到的最大宽度是500。

关于html - Facebook 页面嵌入的 iframe 不填充容器宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56725011/

相关文章:

css - 如何制作可在 Outlook 中使用的填充框?

php - HybridAuth "Tiny Social Hub"示例重定向到/hybridauth/?hauth.start=Facebook&hauth.time

facebook - 使用 Corona sdk 免费版与 friend 共享应用程序

html - 在内容 div 上 float 一个连续包含三个 div 的 div

javascript - 下个月倒计时 - 进度条 - JavaScript

html - 我该怎么做才能让我有 4 行并且结果类使用 flexbox 位于顶部?

jquery - 使用 jQuery 使用 Select 显示/隐藏多个 DIV

iphone - 有没有办法使用 WebKit 以编程方式下载网页以供离线查看?

javascript - 根据另一个元素拟合一个元素

从 facebook oauth 重定向时 django session 丢失