代码之家  ›  专栏  ›  技术社区  ›  ken

Recaptcha固定图像大小

  •  7
  • ken  · 技术社区  · 16 年前

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

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

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

    6 回复  |  直到 16 年前
        1
  •  11
  •   Larry Foobar bumelant    15 年前
    #recaptcha_image img {
        width: 200px !important;
        height: 38px !important;
    }
    
        2
  •  1
  •   MatTheCat    16 年前

    你可以覆盖内联css添加!在css规则背后很重要,即使在外部文件中也是如此。

        3
  •  1
  •   Developer    12 年前

    完全定制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
  •  1
  •   andrea.somovigo    11 年前

    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
  •  0
  •   Muhammad Soliman    12 年前

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

     #recaptcha_area
       {
             width: 250px !important;
             height: 38px !important;
       }
    
        6
  •  0
  •   Muntasim    11 年前

    对于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