【问题标题】:Recaptcha fixed image sizeRecaptcha 固定图像大小
【发布时间】:2011-03-24 07:17:37
【问题描述】:

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

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

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

谢谢

【问题讨论】:

    标签: html css captcha recaptcha


    【解决方案1】:
    #recaptcha_image img {
        width: 200px !important;
        height: 38px !important;
    }
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        使用 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(&#39;audio&#39;)">Get an audio CAPTCHA</a></div>
                                        <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(&#39;image&#39;)">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>
        

        【讨论】:

          【解决方案4】:

          适用于新 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">
          

          【讨论】:

            【解决方案5】:

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

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

            【讨论】:

              【解决方案6】:

              对于新版本的 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 的原始大小。但是上面的解决方案解决了空格问题。

              Ref

              【讨论】:

                猜你喜欢
                • 2017-09-20
                • 2013-08-12
                • 2018-01-20
                • 2021-04-13
                • 2015-10-12
                • 1970-01-01
                • 2016-08-28
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多