No CAPTCHA reCAPTCHA Resizing

前端 未结 14 2001
故里飘歌
故里飘歌 2020-12-14 01:23

Hi I just added Google\'s No CAPTCHA reCAPTCHA to my website, and I am running into a small little issue. It does NOT fit on my mobile website, and that is

14条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 02:05

    For who might be interested, I changed a little AjaxLeung solution and came up with this:

     function resizeReCaptcha() {
        if ($(".g-recaptcha").length) {
            var recaptcha = $(".g-recaptcha");
            recaptcha.parent().addClass('col-xs-12 padding0');
            var innerWidth = recaptcha.parent().innerWidth();
            if (innerWidth < 304) {
                var newScaleFactor = innerWidth / 304;
                recaptcha.css('transform', 'scale(' + newScaleFactor + ')');
                recaptcha.css('-webkit-transform', 'scale(' + newScaleFactor + ')');
                recaptcha.css('transform-origin', '0 0');
                recaptcha.css('-webkit-transform-origin', '0 0');
            } else {
                recaptcha.css('transform', 'scale(1)');
                recaptcha.css('-webkit-transform', 'scale(1)');
                recaptcha.css('transform-origin', '0 0');
                recaptcha.css('-webkit-transform-origin', '0 0');
            }
        }
    }
    
    $(window).resize(function() {
        resizeReCaptcha();
    });
    
    $(document).ready(function () {
        resizeReCaptcha();
    });
    

提交回复
热议问题