Last active
April 25, 2020 10:01
-
-
Save vfontjr/966c0e579ff4d085d40fa5ebe075d875 to your computer and use it in GitHub Desktop.
Source code for https://victorfont.com/resize-google-recaptcha-for-mobile/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.g-recaptcha { | |
transform-origin: left top; | |
-webkit-transform-origin: left top; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
jQuery(document).ready( function ($) { | |
"use strict"; | |
function scaleCaptcha( elementWidth ) { | |
/* Width of the reCAPTCHA element, in pixels */ | |
var reCaptchaWidth = 304; | |
/* Get the containing element's width */ | |
var containerWidth = $('#frm_field_xxx_container').width(); | |
/* Only scale the reCAPTCHA if it won't fit inside the container */ | |
if(reCaptchaWidth > containerWidth) { | |
/* Calculate the scale */ | |
var captchaScale = containerWidth / reCaptchaWidth; | |
/* Apply the transformation */ | |
$('.g-recaptcha').css({ 'transform':'scale('+captchaScale+')' }); | |
} | |
} | |
scaleCaptcha(); | |
/* Update scaling on window resize */ | |
$(window).resize( scaleCaptcha() ); }); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment