Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Last active April 25, 2020 10:01
Show Gist options
  • Save vfontjr/966c0e579ff4d085d40fa5ebe075d875 to your computer and use it in GitHub Desktop.
Save vfontjr/966c0e579ff4d085d40fa5ebe075d875 to your computer and use it in GitHub Desktop.
.g-recaptcha {
transform-origin: left top;
-webkit-transform-origin: left top;
}
<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