使用 iframe 可见性属性时 Facebook Like Box 的大小不正确

发布于 2024-12-21 09:02:01 字数 738 浏览 2 评论 0原文

我正在网页上添加 Facebook Like Box,但在调整大小方面遇到了一些问题。我最初使用 Facebook 开发者网站上的 HTML5 和 Javascript 代码来制作一个我喜欢的盒子,但我发现它在加载时减慢了页面上的其他动画。

然后我决定使用 iFrame,它非常完美,不会减慢页面加载的任何其他元素。为了使它看起来更好,我将这段代码添加到 iframe 中:

style="visibility:hidden;" onload="this.style.visibility = 'visible';"

我也尝试过:

style="display:none;" onload="this.style.display = 'block';"

这可以防止 iframe 在加载时出现白色闪烁(它看起来更优雅;两个代码都给我带来了相同的问题)。但现在,当 Like Box 加载时,它仅加载大约 150 像素的高度(尽管它的高度设置为 250 像素)。当上面的代码被取出时,盒子的大小完美,当我把它放回原处时,它又恢复原状。

有趣的是,当可见性代码进入并且我调整宽度变量时,框的宽度会发生变化。当我调整高度时,它不会改变。

这是我为此制作的小提琴:

http://jsfiddle.net/KWMxb/

有什么想法吗?谢谢!

I'm adding a Facebook Like Box on my webpage and have some trouble with sizing. I originally had used the HTML5 and Javascript code from the Facebook Developer site to make a box to my liking but I found that it was slowing my other animations on the page when it was loading.

I decided to then use an iFrame which is perfect and doesn't slow down any of the other elements of the page onload. To make it look better, I added this code into the iframe:

style="visibility:hidden;" onload="this.style.visibility = 'visible';"

And I've also tried:

style="display:none;" onload="this.style.display = 'block';"

which keeps the iframe from making that white flash when it's loading up (it looks much classier; both codes are giving me the identical problem). Now, though, when the Like Box loads it only loads about 150 pixels in height (although it's set at 250 pixels for height). When the above code is taken out, the box is sized perfectly and when I put it back in it reverts back.

The interesting thing is that when the visibility code is in and I adjust the width variable, the width of the box changes. When I adjust the height though, it doesn't change.

Here's a fiddle I made for it:

http://jsfiddle.net/KWMxb/

Any thoughts? Thanks!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倒带 2024-12-28 09:02:01

您的 iframe 有两个 style 属性。将所有内容从第二个移到第一个,它应该可以工作。

your iframe has two style attributes. Move everything from the second one into the first and it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文