Recaptcha在页面上创建iFrame,破坏了样式。

36

Recaptcha 在我的网站顶部添加了一个“此框架防止 Safari 中的后退/前进缓存问题”的 iFrame(下面包含代码),这使得样式偏移了20-30像素(大约)。

如果我在 Firebug 中将元素的 display: none; 设置为解决了该问题。

有人知道为什么这个元素有高度(我没有应用于 iFrames 的 CSS)吗?或者如何对其设置 display: none;?

<iframe src="about:blank" style="height: 0px; width: 0px; visibility: hidden; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; ">
    This frame prevents back/forward cache problems in Safari.
</iframe>
3个回答

49

尝试以下 CSS:

/* ReCaptcha Iframe FIX */
iframe {display:none !important;}
header iframe,
section iframe,
footer iframe,
div iframe { display:inline; }

如果您不需要担心站点上的其他框架,那么简化版本就足够了:

iframe {display:none !important;}

或者,您可以针对所有src="about:blank"的iframe进行目标定位:

iframe[src="about:blank"]{display:none;}

这里有10个感谢积分,因为你解决了和我一样的问题!=P - Manatax
1
+1,这就是那种让人发疯的东西! - Mike Perrenoud
2
谢谢你。这真的让我抓狂了。顺便说一下:reCAPTCHA API 真的很糟糕...设计它的人让我想死。 - wnajar

24
iframe[src="about:blank"]{display:none;}

这将匹配所有具有“src”属性为“about:blank”的iframe。


应该使用 src 而不是 href 来嵌入 iframe。 - Imre L

5
这似乎更简单、更准确:
body > iframe { display:none !important; }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接