验证码固定图像大小

发布于 2024-09-12 16:09:56 字数 439 浏览 6 评论 0原文

为什么 recaptcha 图像大小固定为 300x57 ?即使在自定义注入图像的 div 时,div 的宽度和高度也会被覆盖并设置为 300x57。当然,图像在渲染后可以重新调整大小,但为什么没有选项来生成开发人员希望的大小的图像。

http://code.google.com/apis/recaptcha/docs/customization.html

reCAPTCHA 将依赖具有以下 ID 的 HTML 元素的存在来向用户显示验证码: ID 为 recaptcha_image 的空 div。这是实际图像放置的位置。 div 将为 300x57 像素

谢谢

Why is recaptcha image fixed in size 300x57 ? Even when customizing the div where the image is injected, the width and height of the div are overridden and set to 300x57. Of course the image can be re-sized after it's rendered, but why there are no options to generate the image the size developers would like it to be.

http://code.google.com/apis/recaptcha/docs/customization.html

reCAPTCHA will rely on the presence of HTML elements with the following IDs to display the CAPTCHA to the user: An empty div with ID recaptcha_image. This is where the actual image will be placed. The div will be 300x57 pixels

Thank you

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

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

发布评论

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

评论(6

残花月 2024-09-19 16:09:56
#recaptcha_image img {
    width: 200px !important;
    height: 38px !important;
}
#recaptcha_image img {
    width: 200px !important;
    height: 38px !important;
}
甜宝宝 2024-09-19 16:09:56

即使在外部文件中,您也可以在 css 规则后面添加 !important 来覆盖内联 css。

You can override inline css adding !important behind a css rule, even in an external file.

A君 2024-09-19 16:09:56

使用 CSS 进行完全自定义,演示

<form method="POST" action="">



<script type="text/javascript">
                                var RecaptchaOptions = {
                                    tabindex: 1,
                                    theme: 'custom',
                                    custom_theme_widget: 'recaptcha_widget'
                                };
                            </script>
                            <div id="recaptcha_widget" style="display:none"><div id="recaptcha_image"></div>
                                <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect, please try again</div>
                                <span class="recaptcha_only_if_image">Enter the words above:</span>
                                <span class="recaptcha_only_if_audio">Type what you hear:</span>
                                <input type="text" id="recaptcha_response_field" name="recaptcha_response_field">
                                <div class="get_another_captcha"><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div>
                                <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
                                <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div>
                                <div><a href="javascript:Recaptcha.showhelp()">Help</a></div>
                                <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=YourAPI"></script>
                                <noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=YourAPI" height="300" width="500" frameborder="0"></iframe><br>
                                <textarea name="recaptcha_challenge_field" rows="3" cols="40">
                                </textarea>
                                <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript></div>
                            <script type="text/javascript">
                                window.onload = function() {
                                    Recaptcha.focus_response_field();
                                }
                            </script>
                            <table cellspacing="0" cellpadding="4" border="0" style="font-family: Helvetica, sans-serif; color: #000000; font-size: 12px;"><tr><td><div><input type="submit" name="Button1" value="Submit"></div></td></tr></table></form>

Full customization with css, demo

<form method="POST" action="">



<script type="text/javascript">
                                var RecaptchaOptions = {
                                    tabindex: 1,
                                    theme: 'custom',
                                    custom_theme_widget: 'recaptcha_widget'
                                };
                            </script>
                            <div id="recaptcha_widget" style="display:none"><div id="recaptcha_image"></div>
                                <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect, please try again</div>
                                <span class="recaptcha_only_if_image">Enter the words above:</span>
                                <span class="recaptcha_only_if_audio">Type what you hear:</span>
                                <input type="text" id="recaptcha_response_field" name="recaptcha_response_field">
                                <div class="get_another_captcha"><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div>
                                <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
                                <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div>
                                <div><a href="javascript:Recaptcha.showhelp()">Help</a></div>
                                <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=YourAPI"></script>
                                <noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=YourAPI" height="300" width="500" frameborder="0"></iframe><br>
                                <textarea name="recaptcha_challenge_field" rows="3" cols="40">
                                </textarea>
                                <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript></div>
                            <script type="text/javascript">
                                window.onload = function() {
                                    Recaptcha.focus_response_field();
                                }
                            </script>
                            <table cellspacing="0" cellpadding="4" border="0" style="font-family: Helvetica, sans-serif; color: #000000; font-size: 12px;"><tr><td><div><input type="submit" name="Button1" value="Submit"></div></td></tr></table></form>
不及他 2024-09-19 16:09:56

适用于新的 google Recaptcha 的解决方案 (https://www.google.com/recaptcha/)

<!--adjust to your needs -->
<div class="g-recaptcha" data-sitekey="your_sitekey" style="transform:scale(.8); margin:0 -30px">

Solution working for the new google Recaptcha (https://www.google.com/recaptcha/)

<!--adjust to your needs -->
<div class="g-recaptcha" data-sitekey="your_sitekey" style="transform:scale(.8); margin:0 -30px">

下雨或天晴 2024-09-19 16:09:56

这对我有用,有效地改变了整个控件的宽度,而不仅仅是内部图像

 #recaptcha_area
   {
         width: 250px !important;
         height: 38px !important;
   }

This worked for me and effectively changed the width of the whole control not only the inner image

 #recaptcha_area
   {
         width: 250px !important;
         height: 38px !important;
   }
一抹淡然 2024-09-19 16:09:56

对于新版本的 noCaptcha Recaptcha,以下内容对我有用:

<div class="g-recaptcha" data-theme="light" data-sitekey="XXXXXXXXXXXXX"      
style="transform:scale(0.77);transform-origin:0;-webkit-transform:scale(0.77);
transform:scale(0.77);-webkit-transform-origin:0;transform-origin:0 0;"></div>

如果仅缩放,则仍采用 div 的原始大小。但上面的解决方案解决了空白问题。

参考

For the new version of noCaptcha Recaptcha the following works for me:

<div class="g-recaptcha" data-theme="light" data-sitekey="XXXXXXXXXXXXX"      
style="transform:scale(0.77);transform-origin:0;-webkit-transform:scale(0.77);
transform:scale(0.77);-webkit-transform-origin:0;transform-origin:0 0;"></div>

If you scale only still it takes the original size of the div. But the solution above fixes the blank space issue.

Ref

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