Recaptcha在页面上创建iFrame,打破样式

Wal*_*ker 36 html css captcha recaptcha

Recaptcha正在添加一个"此框架防止Safari中的后退/转发缓存问题"iFrame到我的网站顶部(下面包含的代码),这样可以将样式推迟20-30px(大约).

如果我设置display: none;为Firebug中的元素,它修复了问题.

有谁知道为什么这个元素有一个高度(我没有适用于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>
Run Code Online (Sandbox Code Playgroud)

Jam*_*ill 49

试试下面的CSS:

/* ReCaptcha Iframe FIX */
iframe {display:none !important;}
header iframe,
section iframe,
footer iframe,
div iframe { display:inline; }
Run Code Online (Sandbox Code Playgroud)

如果您不担心网站上的任何其他框架,更简单的版本应该足够:

iframe {display:none !important;}
Run Code Online (Sandbox Code Playgroud)

或者,您可以定位所有iframe src="about:blank":

iframe[src="about:blank"]{display:none;}
Run Code Online (Sandbox Code Playgroud)

  • 这次真是万分感谢.这真让我疯了.旁注:reCAPTCHA API非常悲惨......任何设计的人都会让我想死. (2认同)

Leo*_*ang 24

iframe[src="about:blank"]{display:none;}
Run Code Online (Sandbox Code Playgroud)

这匹配所有iframe,其"src"属性为"about:blank".


Bre*_*uir 5

这似乎更简单,更准确:

body > iframe { display:none !important; }
Run Code Online (Sandbox Code Playgroud)